abxrcli 0.9.1__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 abxrcli might be problematic. Click here for more details.
- abxrcli-0.9.1/LICENSE +21 -0
- abxrcli-0.9.1/PKG-INFO +217 -0
- abxrcli-0.9.1/README.md +208 -0
- abxrcli-0.9.1/abxr/api_service.py +13 -0
- abxrcli-0.9.1/abxr/apps.py +278 -0
- abxrcli-0.9.1/abxr/cli.py +113 -0
- abxrcli-0.9.1/abxr/files.py +79 -0
- abxrcli-0.9.1/abxr/formats.py +11 -0
- abxrcli-0.9.1/abxr/multipart.py +34 -0
- abxrcli-0.9.1/abxr/version.py +7 -0
- abxrcli-0.9.1/abxrcli.egg-info/PKG-INFO +217 -0
- abxrcli-0.9.1/abxrcli.egg-info/SOURCES.txt +16 -0
- abxrcli-0.9.1/abxrcli.egg-info/dependency_links.txt +1 -0
- abxrcli-0.9.1/abxrcli.egg-info/entry_points.txt +2 -0
- abxrcli-0.9.1/abxrcli.egg-info/top_level.txt +1 -0
- abxrcli-0.9.1/pyproject.toml +18 -0
- abxrcli-0.9.1/setup.cfg +4 -0
- abxrcli-0.9.1/setup.py +19 -0
abxrcli-0.9.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
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.
|
abxrcli-0.9.1/PKG-INFO
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: abxrcli
|
|
3
|
+
Version: 0.9.1
|
|
4
|
+
Summary: ArborXR CLI
|
|
5
|
+
Author-email: Peter Peterson <peter@arborxr.com>
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# ArborXR CLI
|
|
11
|
+
|
|
12
|
+
This CLI tool provides commands for managing apps and files via the ArborXR API. The tool is organized into command groups: apps and files. Each group has several subcommands to perform specific operations through the command line.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
Before using the CLI tool, ensure you have the following:
|
|
17
|
+
* Python 3 installed on your system.
|
|
18
|
+
* An API Token for authentication. See this Knowledge Base article for how to generate an API token for CLI usage: https://help.arborxr.com/en/articles/6333187-cli-tool#h_f1b58ac24e
|
|
19
|
+
* Setting the API token via:
|
|
20
|
+
* The environment variable ABXR_API_TOKEN (or the alternative ARBORXR_ACCESS_TOKEN), or
|
|
21
|
+
* The command line option --token.
|
|
22
|
+
|
|
23
|
+
## Project Setup
|
|
24
|
+
|
|
25
|
+
### Clone the Repository
|
|
26
|
+
```
|
|
27
|
+
git clone https://github.com/arborxr/abxr-cli.git
|
|
28
|
+
cd abxr-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Create and Activate a Virtual Environment
|
|
32
|
+
For best practices, create a virtual environment to isolate your dependencies:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
python3 -m venv venv
|
|
36
|
+
source venv/bin/activate
|
|
37
|
+
```
|
|
38
|
+
*On Windows virtual environment is activated differently*
|
|
39
|
+
```
|
|
40
|
+
venv\Scripts\activate
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Build and Install
|
|
44
|
+
Run the build script to compile the necessary components, then install the CLI tool using the install script:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
./build.sh
|
|
48
|
+
./install.sh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Following these steps will ensure you have a clean, isolated environment you can execute the CLI in.
|
|
52
|
+
|
|
53
|
+
## Global Options
|
|
54
|
+
|
|
55
|
+
### The CLI tool accepts the following global options:
|
|
56
|
+
`-u, --url`
|
|
57
|
+
* Description: API Base URL
|
|
58
|
+
* Default: https://api.xrdm.app/api/v2 (or the value of ABXR_API_URL environment variable)
|
|
59
|
+
|
|
60
|
+
`-t, --token`
|
|
61
|
+
* Description: API Token for authentication
|
|
62
|
+
* Default: Value of ABXR_API_TOKEN (or ARBORXR_ACCESS_TOKEN)
|
|
63
|
+
|
|
64
|
+
`-f, --format`
|
|
65
|
+
* Description: Data output format
|
|
66
|
+
* Choices: json or yaml
|
|
67
|
+
* Default: yaml
|
|
68
|
+
|
|
69
|
+
`-v, --version`
|
|
70
|
+
* Description: Show the CLI tool version and exit
|
|
71
|
+
|
|
72
|
+
## Command Groups
|
|
73
|
+
|
|
74
|
+
The CLI tool is divided into two main groups: apps and files. Each group has its own set of subcommands.
|
|
75
|
+
|
|
76
|
+
### Apps Commands
|
|
77
|
+
|
|
78
|
+
These commands manage app-related operations.
|
|
79
|
+
|
|
80
|
+
#### Subcommands
|
|
81
|
+
|
|
82
|
+
##### list
|
|
83
|
+
* Usage:
|
|
84
|
+
`abxr-cli apps list`
|
|
85
|
+
* Description: List all available apps.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
##### details
|
|
89
|
+
* Usage:
|
|
90
|
+
`abxr-cli apps details <app_id>`
|
|
91
|
+
* Positional Argument:
|
|
92
|
+
* <app_id>: The unique identifier of the app.
|
|
93
|
+
* Description: Retrieve detailed information about a specific app.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
##### versions
|
|
97
|
+
* Usage:
|
|
98
|
+
`abxr-cli apps versions <app_id>`
|
|
99
|
+
* Positional Argument:
|
|
100
|
+
* <app_id>: The unique identifier of the app.
|
|
101
|
+
* Description: List all versions available for a specific app.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
##### release_channels
|
|
105
|
+
* Usage:
|
|
106
|
+
`abxr-cli apps release_channels <app_id>`
|
|
107
|
+
* Positional Argument:
|
|
108
|
+
* <app_id>: The unique identifier of the app.
|
|
109
|
+
* Description: List all release channels associated with a specific app.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
##### release_channel_details
|
|
113
|
+
* Usage:
|
|
114
|
+
`abxr-cli apps release_channel_details <app_id> [--release_channel_id RELEASE_CHANNEL_ID]`
|
|
115
|
+
* Positional Argument:
|
|
116
|
+
* <app_id>: The unique identifier of the app.
|
|
117
|
+
* Optional Argument:
|
|
118
|
+
* --release_channel_id: The identifier for a specific release channel.
|
|
119
|
+
* Description: Get details for a release channel of an app.
|
|
120
|
+
|
|
121
|
+
##### release_channel_set_version
|
|
122
|
+
* Usage:
|
|
123
|
+
`abxr-cli apps release_channel_set_version <app_id> [--release_channel_id RELEASE_CHANNEL_ID] [--version_id VERSION_ID]`
|
|
124
|
+
* Positional Argument:
|
|
125
|
+
* <app_id>: The unique identifier of the app.
|
|
126
|
+
* Optional Arguments:
|
|
127
|
+
* --release_channel_id: The identifier for the release channel.
|
|
128
|
+
* --version_id: The version identifier to set for the channel.
|
|
129
|
+
* Description: Assign a specific version to a release channel.
|
|
130
|
+
|
|
131
|
+
##### upload
|
|
132
|
+
* Usage:
|
|
133
|
+
`abxr-cli apps upload <app_id> <filename> [--version VERSION] [--notes NOTES]`
|
|
134
|
+
* Positional Arguments:
|
|
135
|
+
* <app_id>: The unique identifier of the app.
|
|
136
|
+
* <filename>: Local path of the APK file to upload.
|
|
137
|
+
* Optional Arguments:
|
|
138
|
+
* -v, --version: Version number (note that the APK itself can override this value).
|
|
139
|
+
* -n, --notes: Release notes for the new version.
|
|
140
|
+
* Description: Upload a new version of an app.
|
|
141
|
+
|
|
142
|
+
##### share
|
|
143
|
+
* Usage:
|
|
144
|
+
`abxr-cli apps share <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
145
|
+
* Positional Argument:
|
|
146
|
+
* <app_id>: The unique identifier of the app.
|
|
147
|
+
* Required Options:
|
|
148
|
+
* --release_channel_id: The release channel to be shared.
|
|
149
|
+
* --organization_slug: The organization slug with which the app is to be shared.
|
|
150
|
+
* Description: Share an app with a specific organization and release channel.
|
|
151
|
+
|
|
152
|
+
##### revoke
|
|
153
|
+
* Usage:
|
|
154
|
+
`abxr-cli apps revoke <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
155
|
+
* Positional Argument:
|
|
156
|
+
* <app_id>: The unique identifier of the app.
|
|
157
|
+
* Required Options:
|
|
158
|
+
* --release_channel_id: The release channel from which to revoke sharing.
|
|
159
|
+
* --organization_slug: The organization slug from which the app sharing should be revoked.
|
|
160
|
+
* Description: Revoke sharing of an app from a specific organization and release channel.
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### Files Commands
|
|
164
|
+
|
|
165
|
+
These commands are used for file-related operations.
|
|
166
|
+
|
|
167
|
+
#### Subcommands
|
|
168
|
+
|
|
169
|
+
##### list
|
|
170
|
+
* Usage:
|
|
171
|
+
`abxr-cli files list`
|
|
172
|
+
* Description: List all files available.
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
##### details
|
|
176
|
+
* Usage:
|
|
177
|
+
`abxr-cli files details <file_id>`
|
|
178
|
+
* Positional Argument:
|
|
179
|
+
* <file_id>: The unique identifier of the file.
|
|
180
|
+
* Description: Get detailed information for a specific file.
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
## CLI Usage Examples
|
|
184
|
+
|
|
185
|
+
These examples assume you have set the `ABXR_API_TOKEN` in your environment.
|
|
186
|
+
|
|
187
|
+
### Listing all apps
|
|
188
|
+
|
|
189
|
+
`abxr-cli apps list`
|
|
190
|
+
|
|
191
|
+
### Getting details of a specific app
|
|
192
|
+
|
|
193
|
+
`abxr-cli apps details 123e4567-e89b-12d3-a456-426614174000`
|
|
194
|
+
|
|
195
|
+
### Listing versions of an app
|
|
196
|
+
|
|
197
|
+
`abxr-cli apps versions 123e4567-e89b-12d3-a456-426614174000`
|
|
198
|
+
|
|
199
|
+
### Uploading a new version of an app
|
|
200
|
+
|
|
201
|
+
`abxr-cli apps upload 123e4567-e89b-12d3-a456-426614174000 /path/to/app.apk --version 1.2.3 --notes "Bug fixes and performance improvements"`
|
|
202
|
+
|
|
203
|
+
### Sharing an app with an organization
|
|
204
|
+
|
|
205
|
+
`abxr-cli apps share 123e4567-e89b-12d3-a456-426614174000 --release_channel_id 6789 --organization_slug myorg`
|
|
206
|
+
|
|
207
|
+
### Listing all files
|
|
208
|
+
|
|
209
|
+
`abxr-cli files list`
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## Error Handling
|
|
213
|
+
|
|
214
|
+
* If the API token is missing (not provided via --token or environment variables), the tool will print:
|
|
215
|
+
|
|
216
|
+
`API Token is required. Please set the ABXR_API_TOKEN environment variable or use the --token command line param`
|
|
217
|
+
|
abxrcli-0.9.1/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ArborXR CLI
|
|
2
|
+
|
|
3
|
+
This CLI tool provides commands for managing apps and files via the ArborXR API. The tool is organized into command groups: apps and files. Each group has several subcommands to perform specific operations through the command line.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Before using the CLI tool, ensure you have the following:
|
|
8
|
+
* Python 3 installed on your system.
|
|
9
|
+
* An API Token for authentication. See this Knowledge Base article for how to generate an API token for CLI usage: https://help.arborxr.com/en/articles/6333187-cli-tool#h_f1b58ac24e
|
|
10
|
+
* Setting the API token via:
|
|
11
|
+
* The environment variable ABXR_API_TOKEN (or the alternative ARBORXR_ACCESS_TOKEN), or
|
|
12
|
+
* The command line option --token.
|
|
13
|
+
|
|
14
|
+
## Project Setup
|
|
15
|
+
|
|
16
|
+
### Clone the Repository
|
|
17
|
+
```
|
|
18
|
+
git clone https://github.com/arborxr/abxr-cli.git
|
|
19
|
+
cd abxr-cli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Create and Activate a Virtual Environment
|
|
23
|
+
For best practices, create a virtual environment to isolate your dependencies:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
python3 -m venv venv
|
|
27
|
+
source venv/bin/activate
|
|
28
|
+
```
|
|
29
|
+
*On Windows virtual environment is activated differently*
|
|
30
|
+
```
|
|
31
|
+
venv\Scripts\activate
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Build and Install
|
|
35
|
+
Run the build script to compile the necessary components, then install the CLI tool using the install script:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
./build.sh
|
|
39
|
+
./install.sh
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Following these steps will ensure you have a clean, isolated environment you can execute the CLI in.
|
|
43
|
+
|
|
44
|
+
## Global Options
|
|
45
|
+
|
|
46
|
+
### The CLI tool accepts the following global options:
|
|
47
|
+
`-u, --url`
|
|
48
|
+
* Description: API Base URL
|
|
49
|
+
* Default: https://api.xrdm.app/api/v2 (or the value of ABXR_API_URL environment variable)
|
|
50
|
+
|
|
51
|
+
`-t, --token`
|
|
52
|
+
* Description: API Token for authentication
|
|
53
|
+
* Default: Value of ABXR_API_TOKEN (or ARBORXR_ACCESS_TOKEN)
|
|
54
|
+
|
|
55
|
+
`-f, --format`
|
|
56
|
+
* Description: Data output format
|
|
57
|
+
* Choices: json or yaml
|
|
58
|
+
* Default: yaml
|
|
59
|
+
|
|
60
|
+
`-v, --version`
|
|
61
|
+
* Description: Show the CLI tool version and exit
|
|
62
|
+
|
|
63
|
+
## Command Groups
|
|
64
|
+
|
|
65
|
+
The CLI tool is divided into two main groups: apps and files. Each group has its own set of subcommands.
|
|
66
|
+
|
|
67
|
+
### Apps Commands
|
|
68
|
+
|
|
69
|
+
These commands manage app-related operations.
|
|
70
|
+
|
|
71
|
+
#### Subcommands
|
|
72
|
+
|
|
73
|
+
##### list
|
|
74
|
+
* Usage:
|
|
75
|
+
`abxr-cli apps list`
|
|
76
|
+
* Description: List all available apps.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
##### details
|
|
80
|
+
* Usage:
|
|
81
|
+
`abxr-cli apps details <app_id>`
|
|
82
|
+
* Positional Argument:
|
|
83
|
+
* <app_id>: The unique identifier of the app.
|
|
84
|
+
* Description: Retrieve detailed information about a specific app.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
##### versions
|
|
88
|
+
* Usage:
|
|
89
|
+
`abxr-cli apps versions <app_id>`
|
|
90
|
+
* Positional Argument:
|
|
91
|
+
* <app_id>: The unique identifier of the app.
|
|
92
|
+
* Description: List all versions available for a specific app.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
##### release_channels
|
|
96
|
+
* Usage:
|
|
97
|
+
`abxr-cli apps release_channels <app_id>`
|
|
98
|
+
* Positional Argument:
|
|
99
|
+
* <app_id>: The unique identifier of the app.
|
|
100
|
+
* Description: List all release channels associated with a specific app.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
##### release_channel_details
|
|
104
|
+
* Usage:
|
|
105
|
+
`abxr-cli apps release_channel_details <app_id> [--release_channel_id RELEASE_CHANNEL_ID]`
|
|
106
|
+
* Positional Argument:
|
|
107
|
+
* <app_id>: The unique identifier of the app.
|
|
108
|
+
* Optional Argument:
|
|
109
|
+
* --release_channel_id: The identifier for a specific release channel.
|
|
110
|
+
* Description: Get details for a release channel of an app.
|
|
111
|
+
|
|
112
|
+
##### release_channel_set_version
|
|
113
|
+
* Usage:
|
|
114
|
+
`abxr-cli apps release_channel_set_version <app_id> [--release_channel_id RELEASE_CHANNEL_ID] [--version_id VERSION_ID]`
|
|
115
|
+
* Positional Argument:
|
|
116
|
+
* <app_id>: The unique identifier of the app.
|
|
117
|
+
* Optional Arguments:
|
|
118
|
+
* --release_channel_id: The identifier for the release channel.
|
|
119
|
+
* --version_id: The version identifier to set for the channel.
|
|
120
|
+
* Description: Assign a specific version to a release channel.
|
|
121
|
+
|
|
122
|
+
##### upload
|
|
123
|
+
* Usage:
|
|
124
|
+
`abxr-cli apps upload <app_id> <filename> [--version VERSION] [--notes NOTES]`
|
|
125
|
+
* Positional Arguments:
|
|
126
|
+
* <app_id>: The unique identifier of the app.
|
|
127
|
+
* <filename>: Local path of the APK file to upload.
|
|
128
|
+
* Optional Arguments:
|
|
129
|
+
* -v, --version: Version number (note that the APK itself can override this value).
|
|
130
|
+
* -n, --notes: Release notes for the new version.
|
|
131
|
+
* Description: Upload a new version of an app.
|
|
132
|
+
|
|
133
|
+
##### share
|
|
134
|
+
* Usage:
|
|
135
|
+
`abxr-cli apps share <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
136
|
+
* Positional Argument:
|
|
137
|
+
* <app_id>: The unique identifier of the app.
|
|
138
|
+
* Required Options:
|
|
139
|
+
* --release_channel_id: The release channel to be shared.
|
|
140
|
+
* --organization_slug: The organization slug with which the app is to be shared.
|
|
141
|
+
* Description: Share an app with a specific organization and release channel.
|
|
142
|
+
|
|
143
|
+
##### revoke
|
|
144
|
+
* Usage:
|
|
145
|
+
`abxr-cli apps revoke <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
146
|
+
* Positional Argument:
|
|
147
|
+
* <app_id>: The unique identifier of the app.
|
|
148
|
+
* Required Options:
|
|
149
|
+
* --release_channel_id: The release channel from which to revoke sharing.
|
|
150
|
+
* --organization_slug: The organization slug from which the app sharing should be revoked.
|
|
151
|
+
* Description: Revoke sharing of an app from a specific organization and release channel.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### Files Commands
|
|
155
|
+
|
|
156
|
+
These commands are used for file-related operations.
|
|
157
|
+
|
|
158
|
+
#### Subcommands
|
|
159
|
+
|
|
160
|
+
##### list
|
|
161
|
+
* Usage:
|
|
162
|
+
`abxr-cli files list`
|
|
163
|
+
* Description: List all files available.
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
##### details
|
|
167
|
+
* Usage:
|
|
168
|
+
`abxr-cli files details <file_id>`
|
|
169
|
+
* Positional Argument:
|
|
170
|
+
* <file_id>: The unique identifier of the file.
|
|
171
|
+
* Description: Get detailed information for a specific file.
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## CLI Usage Examples
|
|
175
|
+
|
|
176
|
+
These examples assume you have set the `ABXR_API_TOKEN` in your environment.
|
|
177
|
+
|
|
178
|
+
### Listing all apps
|
|
179
|
+
|
|
180
|
+
`abxr-cli apps list`
|
|
181
|
+
|
|
182
|
+
### Getting details of a specific app
|
|
183
|
+
|
|
184
|
+
`abxr-cli apps details 123e4567-e89b-12d3-a456-426614174000`
|
|
185
|
+
|
|
186
|
+
### Listing versions of an app
|
|
187
|
+
|
|
188
|
+
`abxr-cli apps versions 123e4567-e89b-12d3-a456-426614174000`
|
|
189
|
+
|
|
190
|
+
### Uploading a new version of an app
|
|
191
|
+
|
|
192
|
+
`abxr-cli apps upload 123e4567-e89b-12d3-a456-426614174000 /path/to/app.apk --version 1.2.3 --notes "Bug fixes and performance improvements"`
|
|
193
|
+
|
|
194
|
+
### Sharing an app with an organization
|
|
195
|
+
|
|
196
|
+
`abxr-cli apps share 123e4567-e89b-12d3-a456-426614174000 --release_channel_id 6789 --organization_slug myorg`
|
|
197
|
+
|
|
198
|
+
### Listing all files
|
|
199
|
+
|
|
200
|
+
`abxr-cli files list`
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
## Error Handling
|
|
204
|
+
|
|
205
|
+
* If the API token is missing (not provided via --token or environment variables), the tool will print:
|
|
206
|
+
|
|
207
|
+
`API Token is required. Please set the ABXR_API_TOKEN environment variable or use the --token command line param`
|
|
208
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
3
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
class ApiService:
|
|
7
|
+
def __init__(self, base_url, token):
|
|
8
|
+
self.base_url = base_url
|
|
9
|
+
self.headers = {
|
|
10
|
+
'Authorization': f'Bearer {token}',
|
|
11
|
+
'Content-Type': 'application/json'
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
4
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
import yaml
|
|
9
|
+
from tqdm import tqdm
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
from abxr.api_service import ApiService
|
|
14
|
+
from abxr.multipart import MultipartFileS3
|
|
15
|
+
from abxr.formats import DataOutputFormats
|
|
16
|
+
|
|
17
|
+
class Commands(Enum):
|
|
18
|
+
LIST = "list"
|
|
19
|
+
DETAILS = "details"
|
|
20
|
+
VERSION_LIST = "versions"
|
|
21
|
+
RELEASE_CHANNELS_LIST = "release_channels"
|
|
22
|
+
RELEASE_CHANNEL_DETAILS = "release_channel_details"
|
|
23
|
+
RELEASE_CHANNEL_SET_VERSION = "release_channel_set_version"
|
|
24
|
+
UPLOAD = "upload"
|
|
25
|
+
SHARE = "share"
|
|
26
|
+
REVOKE_SHARE = "revoke"
|
|
27
|
+
|
|
28
|
+
class AppsService(ApiService):
|
|
29
|
+
MAX_PARTS_PER_REQUEST = 4
|
|
30
|
+
|
|
31
|
+
def __init__(self, base_url, token):
|
|
32
|
+
super().__init__(base_url, token)
|
|
33
|
+
|
|
34
|
+
def _initiate_upload(self, app_id, file_name):
|
|
35
|
+
url = f'{self.base_url}/apps/{app_id}/versions'
|
|
36
|
+
data = {'filename': file_name}
|
|
37
|
+
|
|
38
|
+
response = requests.post(url, json=data, headers=self.headers)
|
|
39
|
+
response.raise_for_status()
|
|
40
|
+
|
|
41
|
+
return response.json()
|
|
42
|
+
|
|
43
|
+
def _presigned_url(self, app_id, version_id, upload_id, key, part_numbers):
|
|
44
|
+
url = f'{self.base_url}/apps/{app_id}/versions/{version_id}/pre-sign'
|
|
45
|
+
data = {'key': key,
|
|
46
|
+
'uploadId': upload_id,
|
|
47
|
+
'partNumbers': part_numbers
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
response = requests.post(url, json=data, headers=self.headers)
|
|
51
|
+
response.raise_for_status()
|
|
52
|
+
|
|
53
|
+
return response.json()
|
|
54
|
+
|
|
55
|
+
def _complete_upload(self, app_id, version_id, upload_id, key, parts, version_name, release_notes):
|
|
56
|
+
url = f'{self.base_url}/apps/{app_id}/versions/{version_id}/complete'
|
|
57
|
+
data = {'key': key,
|
|
58
|
+
'uploadId': upload_id,
|
|
59
|
+
'parts': parts,
|
|
60
|
+
'versionName': version_name,
|
|
61
|
+
'releaseNotes': release_notes
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
response = requests.post(url, json=data, headers=self.headers)
|
|
65
|
+
response.raise_for_status()
|
|
66
|
+
|
|
67
|
+
return response.json()
|
|
68
|
+
|
|
69
|
+
def upload_file(self, app_id, file_path, version, release_notes):
|
|
70
|
+
print(f"Uploading {file_path} to app_id {app_id}...")
|
|
71
|
+
|
|
72
|
+
file = MultipartFileS3(file_path)
|
|
73
|
+
|
|
74
|
+
response = self._initiate_upload(app_id, file.file_name)
|
|
75
|
+
|
|
76
|
+
upload_id = response['uploadId']
|
|
77
|
+
key = response['key']
|
|
78
|
+
version_id = response['versionId']
|
|
79
|
+
|
|
80
|
+
part_numbers = list(range(1, file.get_part_numbers() + 1))
|
|
81
|
+
|
|
82
|
+
uploaded_parts = []
|
|
83
|
+
|
|
84
|
+
with tqdm(total=file.get_size(), unit='B', unit_scale=True, desc=f'Uploading {file.file_name}') as pbar:
|
|
85
|
+
for i in range(0, len(part_numbers), self.MAX_PARTS_PER_REQUEST):
|
|
86
|
+
part_numbers_slice = part_numbers[i:i + self.MAX_PARTS_PER_REQUEST]
|
|
87
|
+
|
|
88
|
+
presigned_url_response = self._presigned_url(app_id, version_id, upload_id, key, part_numbers_slice)
|
|
89
|
+
|
|
90
|
+
for item in presigned_url_response:
|
|
91
|
+
part_number = item['partNumber']
|
|
92
|
+
presigned_url = item['presignedUrl']
|
|
93
|
+
|
|
94
|
+
part = file.get_part(part_number)
|
|
95
|
+
response = requests.put(presigned_url, data=part)
|
|
96
|
+
response.raise_for_status()
|
|
97
|
+
|
|
98
|
+
uploaded_parts += [{'partNumber': part_number, 'eTag': response.headers['ETag']}]
|
|
99
|
+
pbar.update(len(part))
|
|
100
|
+
|
|
101
|
+
complete_response = self._complete_upload(app_id, version_id, upload_id, key, uploaded_parts, version, release_notes)
|
|
102
|
+
return complete_response
|
|
103
|
+
|
|
104
|
+
def get_all_apps(self):
|
|
105
|
+
url = f'{self.base_url}/apps?per_page=20'
|
|
106
|
+
|
|
107
|
+
response = requests.get(url, headers=self.headers)
|
|
108
|
+
response.raise_for_status()
|
|
109
|
+
|
|
110
|
+
json = response.json()
|
|
111
|
+
|
|
112
|
+
data = json['data']
|
|
113
|
+
|
|
114
|
+
if json['links']:
|
|
115
|
+
while json['links']['next']:
|
|
116
|
+
response = requests.get(json['links']['next'], headers=self.headers)
|
|
117
|
+
response.raise_for_status()
|
|
118
|
+
json = response.json()
|
|
119
|
+
|
|
120
|
+
data += json['data']
|
|
121
|
+
|
|
122
|
+
return data
|
|
123
|
+
|
|
124
|
+
def get_app_detail(self, app_id):
|
|
125
|
+
url = f'{self.base_url}/apps/{app_id}'
|
|
126
|
+
|
|
127
|
+
response = requests.get(url, headers=self.headers)
|
|
128
|
+
response.raise_for_status()
|
|
129
|
+
|
|
130
|
+
return response.json()
|
|
131
|
+
|
|
132
|
+
def get_all_versions_for_app(self, app_id):
|
|
133
|
+
url = f'{self.base_url}/apps/{app_id}/versions'
|
|
134
|
+
|
|
135
|
+
response = requests.get(url, headers=self.headers)
|
|
136
|
+
response.raise_for_status()
|
|
137
|
+
|
|
138
|
+
json = response.json()
|
|
139
|
+
|
|
140
|
+
data = json['data']
|
|
141
|
+
|
|
142
|
+
if json['links']:
|
|
143
|
+
while json['links']['next']:
|
|
144
|
+
response = requests.get(json['links']['next'], headers=self.headers)
|
|
145
|
+
response.raise_for_status()
|
|
146
|
+
json = response.json()
|
|
147
|
+
|
|
148
|
+
data += json['data']
|
|
149
|
+
|
|
150
|
+
return data
|
|
151
|
+
|
|
152
|
+
def get_all_release_channels_for_app(self, app_id):
|
|
153
|
+
url = f'{self.base_url}/apps/{app_id}/release-channels'
|
|
154
|
+
|
|
155
|
+
response = requests.get(url, headers=self.headers)
|
|
156
|
+
response.raise_for_status()
|
|
157
|
+
|
|
158
|
+
json = response.json()
|
|
159
|
+
|
|
160
|
+
data = json['data']
|
|
161
|
+
|
|
162
|
+
if json['links']:
|
|
163
|
+
while json['links']['next']:
|
|
164
|
+
response = requests.get(json['links']['next'], headers=self.headers)
|
|
165
|
+
response.raise_for_status()
|
|
166
|
+
json = response.json()
|
|
167
|
+
|
|
168
|
+
data += json['data']
|
|
169
|
+
|
|
170
|
+
return data
|
|
171
|
+
|
|
172
|
+
def get_release_channel_detail(self, app_id, release_channel_id):
|
|
173
|
+
url = f'{self.base_url}/apps/{app_id}/release-channels/{release_channel_id}'
|
|
174
|
+
|
|
175
|
+
response = requests.get(url, headers=self.headers)
|
|
176
|
+
response.raise_for_status()
|
|
177
|
+
|
|
178
|
+
return response.json()
|
|
179
|
+
|
|
180
|
+
def set_version_for_release_channel(self, app_id, release_channel_id, version_id):
|
|
181
|
+
url = f'{self.base_url}/apps/{app_id}/release-channels/{release_channel_id}'
|
|
182
|
+
|
|
183
|
+
data = {'versionId': version_id}
|
|
184
|
+
|
|
185
|
+
response = requests.put(url, json=data, headers=self.headers)
|
|
186
|
+
response.raise_for_status()
|
|
187
|
+
|
|
188
|
+
return response.json()
|
|
189
|
+
|
|
190
|
+
def share_app(self, app_id, release_channel_id, organization_slug):
|
|
191
|
+
print(f"Sharing app_id {app_id} with release channel {release_channel_id} to org {organization_slug}...")
|
|
192
|
+
|
|
193
|
+
url = f'{self.base_url}/apps/{app_id}/release-channels/{release_channel_id}/share'
|
|
194
|
+
data = {'organizationSlug': organization_slug}
|
|
195
|
+
|
|
196
|
+
response = requests.post(url, json=data, headers=self.headers)
|
|
197
|
+
response.raise_for_status()
|
|
198
|
+
|
|
199
|
+
return response.json()
|
|
200
|
+
|
|
201
|
+
def revoke_shared_app(self, app_id, release_channel_id, organization_slug):
|
|
202
|
+
print(f"Revoking Share of app_id {app_id} with release channel {release_channel_id} to org {organization_slug}...")
|
|
203
|
+
|
|
204
|
+
url = f'{self.base_url}/apps/{app_id}/release-channels/{release_channel_id}/share'
|
|
205
|
+
data = {'organizationSlug': organization_slug}
|
|
206
|
+
|
|
207
|
+
response = requests.delete(url, json=data, headers=self.headers)
|
|
208
|
+
response.raise_for_status()
|
|
209
|
+
|
|
210
|
+
return response.json()
|
|
211
|
+
|
|
212
|
+
class CommandHandler:
|
|
213
|
+
def __init__(self, args):
|
|
214
|
+
self.args = args
|
|
215
|
+
self.service = AppsService(self.args.url, self.args.token)
|
|
216
|
+
|
|
217
|
+
def run(self):
|
|
218
|
+
if self.args.apps_command == Commands.LIST.value:
|
|
219
|
+
apps_list = self.service.get_all_apps()
|
|
220
|
+
|
|
221
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
222
|
+
print(apps_list)
|
|
223
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
224
|
+
print(yaml.dump(apps_list))
|
|
225
|
+
else:
|
|
226
|
+
print("Invalid output format.")
|
|
227
|
+
|
|
228
|
+
elif self.args.apps_command == Commands.DETAILS.value:
|
|
229
|
+
app_detail = self.service.get_app_detail(self.args.app_id)
|
|
230
|
+
|
|
231
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
232
|
+
print(app_detail)
|
|
233
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
234
|
+
print(yaml.dump(app_detail))
|
|
235
|
+
else:
|
|
236
|
+
print("Invalid output format.")
|
|
237
|
+
|
|
238
|
+
elif self.args.apps_command == Commands.RELEASE_CHANNELS_LIST.value:
|
|
239
|
+
release_channels = self.service.get_all_release_channels_for_app(self.args.app_id)
|
|
240
|
+
|
|
241
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
242
|
+
print(release_channels)
|
|
243
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
244
|
+
print(yaml.dump(release_channels))
|
|
245
|
+
else:
|
|
246
|
+
print("Invalid output format.")
|
|
247
|
+
|
|
248
|
+
elif self.args.apps_command == Commands.RELEASE_CHANNEL_DETAILS.value:
|
|
249
|
+
release_channel_detail = self.service.get_release_channel_detail(self.args.app_id, self.args.release_channel_id)
|
|
250
|
+
|
|
251
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
252
|
+
print(release_channel_detail)
|
|
253
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
254
|
+
print(yaml.dump(release_channel_detail))
|
|
255
|
+
else:
|
|
256
|
+
print("Invalid output format.")
|
|
257
|
+
|
|
258
|
+
elif self.args.apps_command == Commands.VERSION_LIST.value:
|
|
259
|
+
versions = self.service.get_all_versions_for_app(self.args.app_id)
|
|
260
|
+
|
|
261
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
262
|
+
print(versions)
|
|
263
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
264
|
+
print(yaml.dump(versions))
|
|
265
|
+
else:
|
|
266
|
+
print("Invalid output format.")
|
|
267
|
+
|
|
268
|
+
elif self.args.apps_command == Commands.RELEASE_CHANNEL_SET_VERSION.value:
|
|
269
|
+
self.service.set_version_for_release_channel(self.args.app_id, self.args.release_channel_id, self.args.version_id)
|
|
270
|
+
|
|
271
|
+
elif self.args.apps_command == Commands.UPLOAD.value:
|
|
272
|
+
self.service.upload_file(self.args.app_id, self.args.filename, self.args.version, self.args.notes)
|
|
273
|
+
|
|
274
|
+
elif self.args.apps_command == Commands.SHARE.value:
|
|
275
|
+
self.service.share_app(self.args.app_id, self.args.release_channel_id, self.args.organization_slug)
|
|
276
|
+
|
|
277
|
+
elif self.args.apps_command == Commands.REVOKE_SHARE.value:
|
|
278
|
+
self.service.revoke_shared_app(self.args.app_id, self.args.release_channel_id, self.args.organization_slug)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
4
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
from abxr.version import version
|
|
11
|
+
from abxr.formats import DataOutputFormats
|
|
12
|
+
|
|
13
|
+
from abxr.apps import Commands as AppCommands, CommandHandler as AppsCommandHandler
|
|
14
|
+
from abxr.files import Commands as FileCommands, CommandHandler as FilesCommandHandler
|
|
15
|
+
|
|
16
|
+
ABXR_API_URL = os.environ.get("ABXR_API_URL", "https://api.xrdm.app/api/v2")
|
|
17
|
+
ABXR_API_TOKEN = os.environ.get("ABXR_API_TOKEN") or os.environ.get("ARBORXR_ACCESS_TOKEN")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
parser = argparse.ArgumentParser(description=f'%(prog)s {version}')
|
|
22
|
+
parser.add_argument("-u", "--url", help="API Base URL", type=str, default=ABXR_API_URL)
|
|
23
|
+
parser.add_argument("-t", "--token", help="API Token", type=str, default=ABXR_API_TOKEN)
|
|
24
|
+
parser.add_argument("-f", "--format", help="Data Output format", type=str, choices=[DataOutputFormats.JSON.value, DataOutputFormats.YAML.value], default=DataOutputFormats.YAML.value)
|
|
25
|
+
parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {version}')
|
|
26
|
+
|
|
27
|
+
subparsers = parser.add_subparsers(dest="command", help="Sub-command help")
|
|
28
|
+
|
|
29
|
+
apps_parser = subparsers.add_parser("apps", help="Apps command")
|
|
30
|
+
apps_subparsers = apps_parser.add_subparsers(dest="apps_command", help="Apps command help")
|
|
31
|
+
|
|
32
|
+
# List All Apps
|
|
33
|
+
apps_list_parser = apps_subparsers.add_parser(AppCommands.LIST.value, help="List apps")
|
|
34
|
+
|
|
35
|
+
# Detail of App
|
|
36
|
+
app_detail_parser = apps_subparsers.add_parser(AppCommands.DETAILS.value, help="Detail of an app")
|
|
37
|
+
app_detail_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
38
|
+
|
|
39
|
+
# Versions of an App
|
|
40
|
+
versions_list_parser = apps_subparsers.add_parser(AppCommands.VERSION_LIST.value, help="List versions of an app")
|
|
41
|
+
versions_list_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# List Release Channels
|
|
45
|
+
release_channels_list_parser = apps_subparsers.add_parser(AppCommands.RELEASE_CHANNELS_LIST.value, help="List release channels of an app")
|
|
46
|
+
release_channels_list_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
47
|
+
|
|
48
|
+
# Detail of Release Channel
|
|
49
|
+
release_channel_detail_parser = apps_subparsers.add_parser(AppCommands.RELEASE_CHANNEL_DETAILS.value, help="Detail of a release channel")
|
|
50
|
+
release_channel_detail_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
51
|
+
release_channel_detail_parser.add_argument("--release_channel_id", help="ID of the release channel", type=str)
|
|
52
|
+
|
|
53
|
+
# Set Version for Release Channel
|
|
54
|
+
release_channel_set_version_parser = apps_subparsers.add_parser(AppCommands.RELEASE_CHANNEL_SET_VERSION.value, help="Set version for a release channel")
|
|
55
|
+
release_channel_set_version_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
56
|
+
release_channel_set_version_parser.add_argument("--release_channel_id", help="ID of the release channel", type=str)
|
|
57
|
+
release_channel_set_version_parser.add_argument("--version_id", help="ID of the version", type=str)
|
|
58
|
+
|
|
59
|
+
# Upload and Create Version
|
|
60
|
+
create_version_parser = apps_subparsers.add_parser(AppCommands.UPLOAD.value, help="Upload a new version of an app")
|
|
61
|
+
create_version_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
62
|
+
create_version_parser.add_argument("filename", help="Local path of the APK to upload", type=str)
|
|
63
|
+
create_version_parser.add_argument("-v", "--version", help="Version Number (APK can override this value)", type=str)
|
|
64
|
+
create_version_parser.add_argument("-n", "--notes", help="Release Notes", type=str)
|
|
65
|
+
|
|
66
|
+
# Sharing Apps
|
|
67
|
+
share_parser = apps_subparsers.add_parser(AppCommands.SHARE.value, help="Share an app")
|
|
68
|
+
share_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
69
|
+
share_parser.add_argument("--release_channel_id", help="ID of the release channel to share", type=str, required=True)
|
|
70
|
+
share_parser.add_argument("--organization_slug", help="Slug of the organization to share with", type=str, required=True)
|
|
71
|
+
|
|
72
|
+
# Revoke Sharing
|
|
73
|
+
revoke_share_parser = apps_subparsers.add_parser(AppCommands.REVOKE_SHARE.value, help="Revoke sharing of an app")
|
|
74
|
+
revoke_share_parser.add_argument("app_id", help="ID of the app", type=str)
|
|
75
|
+
revoke_share_parser.add_argument("--release_channel_id", help="ID of the release channel to revoke", type=str, required=True)
|
|
76
|
+
revoke_share_parser.add_argument("--organization_slug", help="Slug of the organization to revoke from", type=str, required=True)
|
|
77
|
+
|
|
78
|
+
files_parser = subparsers.add_parser("files", help="Files command")
|
|
79
|
+
files_subparsers = files_parser.add_subparsers(dest="files_command", help="Files command help")
|
|
80
|
+
|
|
81
|
+
# List All Files
|
|
82
|
+
files_list_parser = files_subparsers.add_parser(FileCommands.LIST.value, help="List files")
|
|
83
|
+
|
|
84
|
+
# Detail of File
|
|
85
|
+
file_detail_parser = files_subparsers.add_parser(FileCommands.DETAILS.value, help="Detail of a file")
|
|
86
|
+
file_detail_parser.add_argument("file_id", help="ID of the file", type=str)
|
|
87
|
+
|
|
88
|
+
# Upload a file
|
|
89
|
+
upload_file_parser = files_subparsers.add_parser(FileCommands.UPLOAD.value, help="Upload a file")
|
|
90
|
+
upload_file_parser.add_argument("filename", help="Local path of the file to upload", type=str)
|
|
91
|
+
upload_file_parser.add_argument("-p", "--path", help="Path of the file on the device", type=str)
|
|
92
|
+
|
|
93
|
+
args = parser.parse_args()
|
|
94
|
+
|
|
95
|
+
if args.url is None:
|
|
96
|
+
print("API URL is required")
|
|
97
|
+
exit(1)
|
|
98
|
+
|
|
99
|
+
if args.token is None:
|
|
100
|
+
print("API Token is required. Please set the ABXR_API_TOKEN environment variable or use the --token command line param.")
|
|
101
|
+
exit(1)
|
|
102
|
+
|
|
103
|
+
if args.command == "apps":
|
|
104
|
+
handler = AppsCommandHandler(args)
|
|
105
|
+
handler.run()
|
|
106
|
+
|
|
107
|
+
elif args.command == "files":
|
|
108
|
+
handler = FilesCommandHandler(args)
|
|
109
|
+
handler.run()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
main()
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
4
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
import yaml
|
|
9
|
+
from tqdm import tqdm
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
from abxr.api_service import ApiService
|
|
14
|
+
from abxr.multipart import MultipartFileS3
|
|
15
|
+
from abxr.formats import DataOutputFormats
|
|
16
|
+
|
|
17
|
+
class Commands(Enum):
|
|
18
|
+
LIST = "list"
|
|
19
|
+
DETAILS = "details"
|
|
20
|
+
UPLOAD = "upload"
|
|
21
|
+
|
|
22
|
+
class FilesService(ApiService):
|
|
23
|
+
def __init__(self, base_url, token):
|
|
24
|
+
super().__init__(base_url, token)
|
|
25
|
+
|
|
26
|
+
def get_all_files(self):
|
|
27
|
+
url = f'{self.base_url}/files?per_page=20'
|
|
28
|
+
|
|
29
|
+
response = requests.get(url, headers=self.headers)
|
|
30
|
+
response.raise_for_status()
|
|
31
|
+
|
|
32
|
+
json = response.json()
|
|
33
|
+
|
|
34
|
+
data = json['data']
|
|
35
|
+
|
|
36
|
+
if json['links']:
|
|
37
|
+
while json['links']['next']:
|
|
38
|
+
response = requests.get(json['links']['next'], headers=self.headers)
|
|
39
|
+
response.raise_for_status()
|
|
40
|
+
json = response.json()
|
|
41
|
+
|
|
42
|
+
data += json['data']
|
|
43
|
+
|
|
44
|
+
return data
|
|
45
|
+
|
|
46
|
+
def get_file_detail(self, file_id):
|
|
47
|
+
url = f'{self.base_url}/files/{file_id}'
|
|
48
|
+
|
|
49
|
+
response = requests.get(url, headers=self.headers)
|
|
50
|
+
response.raise_for_status()
|
|
51
|
+
|
|
52
|
+
return response.json()
|
|
53
|
+
|
|
54
|
+
class CommandHandler:
|
|
55
|
+
def __init__(self, args):
|
|
56
|
+
self.args = args
|
|
57
|
+
self.service = FilesService(self.args.url, self.args.token)
|
|
58
|
+
|
|
59
|
+
def run(self):
|
|
60
|
+
if self.args.files_command == Commands.LIST.value:
|
|
61
|
+
files_list = self.service.get_all_files()
|
|
62
|
+
|
|
63
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
64
|
+
print(files_list)
|
|
65
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
66
|
+
print(yaml.dump(files_list))
|
|
67
|
+
else:
|
|
68
|
+
print("Invalid output format.")
|
|
69
|
+
|
|
70
|
+
elif self.args.files_command == Commands.DETAILS.value:
|
|
71
|
+
file_detail = self.service.get_file_detail(self.args.file_id)
|
|
72
|
+
|
|
73
|
+
if self.args.format == DataOutputFormats.JSON.value:
|
|
74
|
+
print(file_detail)
|
|
75
|
+
elif self.args.format == DataOutputFormats.YAML.value:
|
|
76
|
+
print(yaml.dump(file_detail))
|
|
77
|
+
else:
|
|
78
|
+
print("Invalid output format.")
|
|
79
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
3
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
class MultipartFileS3:
|
|
9
|
+
MAX_PARTS = 1000
|
|
10
|
+
MIN_PART_SIZE = 5 * 1024 * 1024
|
|
11
|
+
MAX_PART_SIZE = 5 * 1024 * 1024 * 1024
|
|
12
|
+
|
|
13
|
+
def __init__(self, file_path):
|
|
14
|
+
self.file_path = file_path
|
|
15
|
+
self.file_name = file_path.split('/')[-1]
|
|
16
|
+
self.size = self.get_size()
|
|
17
|
+
self.part_size = self.get_part_size()
|
|
18
|
+
self.part_numbers = self.get_part_numbers()
|
|
19
|
+
|
|
20
|
+
def get_size(self):
|
|
21
|
+
return os.path.getsize(self.file_path)
|
|
22
|
+
|
|
23
|
+
def get_part_size(self):
|
|
24
|
+
part_size = self.size // self.MAX_PARTS
|
|
25
|
+
return max(min(part_size, self.MAX_PART_SIZE), self.MIN_PART_SIZE)
|
|
26
|
+
|
|
27
|
+
def get_part_numbers(self):
|
|
28
|
+
return self.size // self.part_size + (1 if self.size % self.part_size > 0 else 0)
|
|
29
|
+
|
|
30
|
+
def get_part(self, part_number):
|
|
31
|
+
part_index = part_number - 1
|
|
32
|
+
with open(self.file_path, 'rb') as file:
|
|
33
|
+
file.seek(part_index * self.part_size)
|
|
34
|
+
return file.read(self.part_size)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: abxrcli
|
|
3
|
+
Version: 0.9.1
|
|
4
|
+
Summary: ArborXR CLI
|
|
5
|
+
Author-email: Peter Peterson <peter@arborxr.com>
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# ArborXR CLI
|
|
11
|
+
|
|
12
|
+
This CLI tool provides commands for managing apps and files via the ArborXR API. The tool is organized into command groups: apps and files. Each group has several subcommands to perform specific operations through the command line.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
Before using the CLI tool, ensure you have the following:
|
|
17
|
+
* Python 3 installed on your system.
|
|
18
|
+
* An API Token for authentication. See this Knowledge Base article for how to generate an API token for CLI usage: https://help.arborxr.com/en/articles/6333187-cli-tool#h_f1b58ac24e
|
|
19
|
+
* Setting the API token via:
|
|
20
|
+
* The environment variable ABXR_API_TOKEN (or the alternative ARBORXR_ACCESS_TOKEN), or
|
|
21
|
+
* The command line option --token.
|
|
22
|
+
|
|
23
|
+
## Project Setup
|
|
24
|
+
|
|
25
|
+
### Clone the Repository
|
|
26
|
+
```
|
|
27
|
+
git clone https://github.com/arborxr/abxr-cli.git
|
|
28
|
+
cd abxr-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Create and Activate a Virtual Environment
|
|
32
|
+
For best practices, create a virtual environment to isolate your dependencies:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
python3 -m venv venv
|
|
36
|
+
source venv/bin/activate
|
|
37
|
+
```
|
|
38
|
+
*On Windows virtual environment is activated differently*
|
|
39
|
+
```
|
|
40
|
+
venv\Scripts\activate
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Build and Install
|
|
44
|
+
Run the build script to compile the necessary components, then install the CLI tool using the install script:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
./build.sh
|
|
48
|
+
./install.sh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Following these steps will ensure you have a clean, isolated environment you can execute the CLI in.
|
|
52
|
+
|
|
53
|
+
## Global Options
|
|
54
|
+
|
|
55
|
+
### The CLI tool accepts the following global options:
|
|
56
|
+
`-u, --url`
|
|
57
|
+
* Description: API Base URL
|
|
58
|
+
* Default: https://api.xrdm.app/api/v2 (or the value of ABXR_API_URL environment variable)
|
|
59
|
+
|
|
60
|
+
`-t, --token`
|
|
61
|
+
* Description: API Token for authentication
|
|
62
|
+
* Default: Value of ABXR_API_TOKEN (or ARBORXR_ACCESS_TOKEN)
|
|
63
|
+
|
|
64
|
+
`-f, --format`
|
|
65
|
+
* Description: Data output format
|
|
66
|
+
* Choices: json or yaml
|
|
67
|
+
* Default: yaml
|
|
68
|
+
|
|
69
|
+
`-v, --version`
|
|
70
|
+
* Description: Show the CLI tool version and exit
|
|
71
|
+
|
|
72
|
+
## Command Groups
|
|
73
|
+
|
|
74
|
+
The CLI tool is divided into two main groups: apps and files. Each group has its own set of subcommands.
|
|
75
|
+
|
|
76
|
+
### Apps Commands
|
|
77
|
+
|
|
78
|
+
These commands manage app-related operations.
|
|
79
|
+
|
|
80
|
+
#### Subcommands
|
|
81
|
+
|
|
82
|
+
##### list
|
|
83
|
+
* Usage:
|
|
84
|
+
`abxr-cli apps list`
|
|
85
|
+
* Description: List all available apps.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
##### details
|
|
89
|
+
* Usage:
|
|
90
|
+
`abxr-cli apps details <app_id>`
|
|
91
|
+
* Positional Argument:
|
|
92
|
+
* <app_id>: The unique identifier of the app.
|
|
93
|
+
* Description: Retrieve detailed information about a specific app.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
##### versions
|
|
97
|
+
* Usage:
|
|
98
|
+
`abxr-cli apps versions <app_id>`
|
|
99
|
+
* Positional Argument:
|
|
100
|
+
* <app_id>: The unique identifier of the app.
|
|
101
|
+
* Description: List all versions available for a specific app.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
##### release_channels
|
|
105
|
+
* Usage:
|
|
106
|
+
`abxr-cli apps release_channels <app_id>`
|
|
107
|
+
* Positional Argument:
|
|
108
|
+
* <app_id>: The unique identifier of the app.
|
|
109
|
+
* Description: List all release channels associated with a specific app.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
##### release_channel_details
|
|
113
|
+
* Usage:
|
|
114
|
+
`abxr-cli apps release_channel_details <app_id> [--release_channel_id RELEASE_CHANNEL_ID]`
|
|
115
|
+
* Positional Argument:
|
|
116
|
+
* <app_id>: The unique identifier of the app.
|
|
117
|
+
* Optional Argument:
|
|
118
|
+
* --release_channel_id: The identifier for a specific release channel.
|
|
119
|
+
* Description: Get details for a release channel of an app.
|
|
120
|
+
|
|
121
|
+
##### release_channel_set_version
|
|
122
|
+
* Usage:
|
|
123
|
+
`abxr-cli apps release_channel_set_version <app_id> [--release_channel_id RELEASE_CHANNEL_ID] [--version_id VERSION_ID]`
|
|
124
|
+
* Positional Argument:
|
|
125
|
+
* <app_id>: The unique identifier of the app.
|
|
126
|
+
* Optional Arguments:
|
|
127
|
+
* --release_channel_id: The identifier for the release channel.
|
|
128
|
+
* --version_id: The version identifier to set for the channel.
|
|
129
|
+
* Description: Assign a specific version to a release channel.
|
|
130
|
+
|
|
131
|
+
##### upload
|
|
132
|
+
* Usage:
|
|
133
|
+
`abxr-cli apps upload <app_id> <filename> [--version VERSION] [--notes NOTES]`
|
|
134
|
+
* Positional Arguments:
|
|
135
|
+
* <app_id>: The unique identifier of the app.
|
|
136
|
+
* <filename>: Local path of the APK file to upload.
|
|
137
|
+
* Optional Arguments:
|
|
138
|
+
* -v, --version: Version number (note that the APK itself can override this value).
|
|
139
|
+
* -n, --notes: Release notes for the new version.
|
|
140
|
+
* Description: Upload a new version of an app.
|
|
141
|
+
|
|
142
|
+
##### share
|
|
143
|
+
* Usage:
|
|
144
|
+
`abxr-cli apps share <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
145
|
+
* Positional Argument:
|
|
146
|
+
* <app_id>: The unique identifier of the app.
|
|
147
|
+
* Required Options:
|
|
148
|
+
* --release_channel_id: The release channel to be shared.
|
|
149
|
+
* --organization_slug: The organization slug with which the app is to be shared.
|
|
150
|
+
* Description: Share an app with a specific organization and release channel.
|
|
151
|
+
|
|
152
|
+
##### revoke
|
|
153
|
+
* Usage:
|
|
154
|
+
`abxr-cli apps revoke <app_id> --release_channel_id RELEASE_CHANNEL_ID --organization_slug ORGANIZATION_SLUG`
|
|
155
|
+
* Positional Argument:
|
|
156
|
+
* <app_id>: The unique identifier of the app.
|
|
157
|
+
* Required Options:
|
|
158
|
+
* --release_channel_id: The release channel from which to revoke sharing.
|
|
159
|
+
* --organization_slug: The organization slug from which the app sharing should be revoked.
|
|
160
|
+
* Description: Revoke sharing of an app from a specific organization and release channel.
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### Files Commands
|
|
164
|
+
|
|
165
|
+
These commands are used for file-related operations.
|
|
166
|
+
|
|
167
|
+
#### Subcommands
|
|
168
|
+
|
|
169
|
+
##### list
|
|
170
|
+
* Usage:
|
|
171
|
+
`abxr-cli files list`
|
|
172
|
+
* Description: List all files available.
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
##### details
|
|
176
|
+
* Usage:
|
|
177
|
+
`abxr-cli files details <file_id>`
|
|
178
|
+
* Positional Argument:
|
|
179
|
+
* <file_id>: The unique identifier of the file.
|
|
180
|
+
* Description: Get detailed information for a specific file.
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
## CLI Usage Examples
|
|
184
|
+
|
|
185
|
+
These examples assume you have set the `ABXR_API_TOKEN` in your environment.
|
|
186
|
+
|
|
187
|
+
### Listing all apps
|
|
188
|
+
|
|
189
|
+
`abxr-cli apps list`
|
|
190
|
+
|
|
191
|
+
### Getting details of a specific app
|
|
192
|
+
|
|
193
|
+
`abxr-cli apps details 123e4567-e89b-12d3-a456-426614174000`
|
|
194
|
+
|
|
195
|
+
### Listing versions of an app
|
|
196
|
+
|
|
197
|
+
`abxr-cli apps versions 123e4567-e89b-12d3-a456-426614174000`
|
|
198
|
+
|
|
199
|
+
### Uploading a new version of an app
|
|
200
|
+
|
|
201
|
+
`abxr-cli apps upload 123e4567-e89b-12d3-a456-426614174000 /path/to/app.apk --version 1.2.3 --notes "Bug fixes and performance improvements"`
|
|
202
|
+
|
|
203
|
+
### Sharing an app with an organization
|
|
204
|
+
|
|
205
|
+
`abxr-cli apps share 123e4567-e89b-12d3-a456-426614174000 --release_channel_id 6789 --organization_slug myorg`
|
|
206
|
+
|
|
207
|
+
### Listing all files
|
|
208
|
+
|
|
209
|
+
`abxr-cli files list`
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## Error Handling
|
|
213
|
+
|
|
214
|
+
* If the API token is missing (not provided via --token or environment variables), the tool will print:
|
|
215
|
+
|
|
216
|
+
`API Token is required. Please set the ABXR_API_TOKEN environment variable or use the --token command line param`
|
|
217
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
abxr/api_service.py
|
|
6
|
+
abxr/apps.py
|
|
7
|
+
abxr/cli.py
|
|
8
|
+
abxr/files.py
|
|
9
|
+
abxr/formats.py
|
|
10
|
+
abxr/multipart.py
|
|
11
|
+
abxr/version.py
|
|
12
|
+
abxrcli.egg-info/PKG-INFO
|
|
13
|
+
abxrcli.egg-info/SOURCES.txt
|
|
14
|
+
abxrcli.egg-info/dependency_links.txt
|
|
15
|
+
abxrcli.egg-info/entry_points.txt
|
|
16
|
+
abxrcli.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
abxr
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "abxrcli"
|
|
7
|
+
version = "0.9.1"
|
|
8
|
+
description = "ArborXR CLI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Peter Peterson", email = "peter@arborxr.com" }]
|
|
11
|
+
|
|
12
|
+
dependencies = [
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
abxr-cli = "abxr.cli:main"
|
|
17
|
+
|
|
18
|
+
|
abxrcli-0.9.1/setup.cfg
ADDED
abxrcli-0.9.1/setup.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024-2025 ABXR Labs, Inc.
|
|
3
|
+
# Released under the MIT License. See LICENSE file for details.
|
|
4
|
+
#
|
|
5
|
+
from setuptools import setup
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name = 'abxrcli',
|
|
9
|
+
version = '0.9.1',
|
|
10
|
+
packages = ['abxr'],
|
|
11
|
+
entry_points = {
|
|
12
|
+
'console_scripts': [
|
|
13
|
+
'abxr-cli = abxr.cli:main',
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
install_requires = [
|
|
17
|
+
],
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
)
|