jvcli 2.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.
- jvcli-2.0.0/LICENSE +201 -0
- jvcli-2.0.0/MANIFEST.in +2 -0
- jvcli-2.0.0/PKG-INFO +24 -0
- jvcli-2.0.0/README.md +87 -0
- jvcli-2.0.0/jvcli/__init__.py +8 -0
- jvcli-2.0.0/jvcli/api.py +318 -0
- jvcli-2.0.0/jvcli/auth.py +45 -0
- jvcli-2.0.0/jvcli/cli.py +36 -0
- jvcli-2.0.0/jvcli/client/assets/index-BtFItD2q.js +156 -0
- jvcli-2.0.0/jvcli/client/assets/index-CIEsu-TC.css +1 -0
- jvcli-2.0.0/jvcli/client/index.html +15 -0
- jvcli-2.0.0/jvcli/client/jac_logo.png +0 -0
- jvcli-2.0.0/jvcli/client/tauri.svg +6 -0
- jvcli-2.0.0/jvcli/client/vite.svg +1 -0
- jvcli-2.0.0/jvcli/commands/__init__.py +1 -0
- jvcli-2.0.0/jvcli/commands/auth.py +46 -0
- jvcli-2.0.0/jvcli/commands/create.py +452 -0
- jvcli-2.0.0/jvcli/commands/download.py +111 -0
- jvcli-2.0.0/jvcli/commands/info.py +91 -0
- jvcli-2.0.0/jvcli/commands/publish.py +207 -0
- jvcli-2.0.0/jvcli/commands/studio.py +96 -0
- jvcli-2.0.0/jvcli/commands/update.py +67 -0
- jvcli-2.0.0/jvcli/templates/2.0.0/action_info.yaml +14 -0
- jvcli-2.0.0/jvcli/templates/2.0.0/agent_descriptor.yaml +30 -0
- jvcli-2.0.0/jvcli/templates/2.0.0/agent_info.yaml +10 -0
- jvcli-2.0.0/jvcli/templates/2.0.0/agent_knowledge.yaml +14 -0
- jvcli-2.0.0/jvcli/templates/2.0.0/agent_memory.yaml +1 -0
- jvcli-2.0.0/jvcli/templates/CHANGELOG.md +2 -0
- jvcli-2.0.0/jvcli/templates/README.md +4 -0
- jvcli-2.0.0/jvcli/utils.py +209 -0
- jvcli-2.0.0/jvcli.egg-info/PKG-INFO +24 -0
- jvcli-2.0.0/jvcli.egg-info/SOURCES.txt +46 -0
- jvcli-2.0.0/jvcli.egg-info/dependency_links.txt +1 -0
- jvcli-2.0.0/jvcli.egg-info/entry_points.txt +2 -0
- jvcli-2.0.0/jvcli.egg-info/requires.txt +11 -0
- jvcli-2.0.0/jvcli.egg-info/top_level.txt +1 -0
- jvcli-2.0.0/setup.cfg +4 -0
- jvcli-2.0.0/setup.py +53 -0
- jvcli-2.0.0/tests/test_api.py +949 -0
- jvcli-2.0.0/tests/test_auth.py +316 -0
- jvcli-2.0.0/tests/test_cli.py +45 -0
- jvcli-2.0.0/tests/test_create.py +383 -0
- jvcli-2.0.0/tests/test_download.py +255 -0
- jvcli-2.0.0/tests/test_info.py +230 -0
- jvcli-2.0.0/tests/test_publish.py +393 -0
- jvcli-2.0.0/tests/test_studio.py +153 -0
- jvcli-2.0.0/tests/test_update.py +103 -0
- jvcli-2.0.0/tests/test_utils.py +390 -0
jvcli-2.0.0/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
jvcli-2.0.0/MANIFEST.in
ADDED
jvcli-2.0.0/PKG-INFO
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: jvcli
|
3
|
+
Version: 2.0.0
|
4
|
+
Summary: CLI tool for Jivas Package Repository
|
5
|
+
Author: TrueSelph Inc.
|
6
|
+
Author-email: admin@trueselph.com
|
7
|
+
Requires-Python: >=3.12
|
8
|
+
License-File: LICENSE
|
9
|
+
Requires-Dist: click>=8.1.8
|
10
|
+
Requires-Dist: requests>=2.32.3
|
11
|
+
Requires-Dist: packaging>=24.2
|
12
|
+
Requires-Dist: pyaml>=25.1.0
|
13
|
+
Requires-Dist: jac-cloud>=0.1.19
|
14
|
+
Provides-Extra: dev
|
15
|
+
Requires-Dist: pre-commit; extra == "dev"
|
16
|
+
Requires-Dist: pytest; extra == "dev"
|
17
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
18
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
19
|
+
Dynamic: author
|
20
|
+
Dynamic: author-email
|
21
|
+
Dynamic: provides-extra
|
22
|
+
Dynamic: requires-dist
|
23
|
+
Dynamic: requires-python
|
24
|
+
Dynamic: summary
|
jvcli-2.0.0/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# JIVAS Command Line Interface (JVCLI)
|
2
|
+
|
3
|
+

|
4
|
+

|
5
|
+

|
6
|
+

|
7
|
+

|
8
|
+
|
9
|
+
`jvcli` is a powerful command-line interface tool designed to streamline interactions with the Jivas Package Repository ([https://jpr.trueselph.com/](https://jpr.trueselph.com/)). It simplifies package management, user authentication, and namespace operations, ensuring seamless software development and deployment. It allows you to create, publish, update, download, and get information about various resources such as actions and agents.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
To install `jvcli`, use `pip`:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
pip install jvcli
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To use `jvcli`, you need to log in first:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
jvcli login
|
25
|
+
```
|
26
|
+
|
27
|
+
After logging in, you can use any of the available commands. For example, to create a new action:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
jvcli create action --name my_action --version 0.0.1 --description "My first action"
|
31
|
+
```
|
32
|
+
|
33
|
+
To publish an action:
|
34
|
+
|
35
|
+
```sh
|
36
|
+
jvcli publish action --path ./my_action --visibility public
|
37
|
+
```
|
38
|
+
|
39
|
+
For more detailed usage, refer to the help command:
|
40
|
+
|
41
|
+
```sh
|
42
|
+
jvcli --help
|
43
|
+
```
|
44
|
+
|
45
|
+
## 🔰 Contributing
|
46
|
+
|
47
|
+
- **🐛 [Report Issues](https://github.com/TrueSelph/jvcli/issues)**: Submit bugs found or log feature requests for the `jvcli` project.
|
48
|
+
- **💡 [Submit Pull Requests](https://github.com/TrueSelph/jvcli/blob/main/CONTRIBUTING.md)**: Review open PRs, and submit your own PRs.
|
49
|
+
|
50
|
+
<details closed>
|
51
|
+
<summary>Contributing Guidelines</summary>
|
52
|
+
|
53
|
+
1. **Fork the Repository**: Start by forking the project repository to your github account.
|
54
|
+
2. **Clone Locally**: Clone the forked repository to your local machine using a git client.
|
55
|
+
```sh
|
56
|
+
git clone https://github.com/TrueSelph/jvcli
|
57
|
+
```
|
58
|
+
3. **Create a New Branch**: Always work on a new branch, giving it a descriptive name.
|
59
|
+
```sh
|
60
|
+
git checkout -b new-feature-x
|
61
|
+
```
|
62
|
+
4. **Make Your Changes**: Develop and test your changes locally.
|
63
|
+
5. **Commit Your Changes**: Commit with a clear message describing your updates.
|
64
|
+
```sh
|
65
|
+
git commit -m 'Implemented new feature x.'
|
66
|
+
```
|
67
|
+
6. **Push to github**: Push the changes to your forked repository.
|
68
|
+
```sh
|
69
|
+
git push origin new-feature-x
|
70
|
+
```
|
71
|
+
7. **Submit a Pull Request**: Create a PR against the original project repository. Clearly describe the changes and their motivations.
|
72
|
+
8. **Review**: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
|
73
|
+
</details>
|
74
|
+
|
75
|
+
<details open>
|
76
|
+
<summary>Contributor Graph</summary>
|
77
|
+
<br>
|
78
|
+
<p align="left">
|
79
|
+
<a href="https://github.com/TrueSelph/jvcli/graphs/contributors">
|
80
|
+
<img src="https://contrib.rocks/image?repo=TrueSelph/jvcli" />
|
81
|
+
</a>
|
82
|
+
</p>
|
83
|
+
</details>
|
84
|
+
|
85
|
+
## 🎗 License
|
86
|
+
|
87
|
+
This project is protected under the Apache License 2.0. See [LICENSE](./LICENSE) for more information.
|
jvcli-2.0.0/jvcli/api.py
ADDED
@@ -0,0 +1,318 @@
|
|
1
|
+
"""This module contains the API class for interacting with the Jivas Package Repository."""
|
2
|
+
|
3
|
+
from typing import Optional
|
4
|
+
|
5
|
+
import click
|
6
|
+
import requests
|
7
|
+
|
8
|
+
|
9
|
+
class RegistryAPI:
|
10
|
+
"""Class for interacting with the Jivas Package Repository API."""
|
11
|
+
|
12
|
+
url = "https://api-jpr.trueselph.com/"
|
13
|
+
|
14
|
+
@staticmethod
|
15
|
+
def signup(username: str, email: str, password: str) -> dict:
|
16
|
+
"""Sign up for a Jivas Package Repository account."""
|
17
|
+
endpoint = "signup"
|
18
|
+
|
19
|
+
try:
|
20
|
+
data = {"username": username, "email": email, "password": password}
|
21
|
+
response = requests.post(RegistryAPI.url + endpoint, json=data)
|
22
|
+
|
23
|
+
# Check if the response is successful
|
24
|
+
if response.status_code == 200:
|
25
|
+
# Include email in the response
|
26
|
+
response_data = response.json()
|
27
|
+
response_data["email"] = email
|
28
|
+
return response_data
|
29
|
+
else:
|
30
|
+
click.secho(f"Error signing up: {response.json()['error']}", fg="red")
|
31
|
+
return {}
|
32
|
+
except Exception as e:
|
33
|
+
click.secho(f"Error signing up: {e}", fg="red")
|
34
|
+
return {}
|
35
|
+
|
36
|
+
@staticmethod
|
37
|
+
def login(email: str, password: str) -> dict:
|
38
|
+
"""Log in to your Jivas Package Repository account."""
|
39
|
+
endpoint = "login"
|
40
|
+
|
41
|
+
try:
|
42
|
+
data = {"emailOrUsername": email, "password": password}
|
43
|
+
response = requests.post(RegistryAPI.url + endpoint, json=data)
|
44
|
+
|
45
|
+
# Check if the response is successful
|
46
|
+
if response.status_code == 200:
|
47
|
+
# Include email in the response
|
48
|
+
response_data = response.json()
|
49
|
+
response_data["email"] = email
|
50
|
+
return response_data
|
51
|
+
else:
|
52
|
+
click.secho(f"Error logging in: {response.json()['error']}", fg="red")
|
53
|
+
return {}
|
54
|
+
except Exception as e:
|
55
|
+
click.secho(f"Error logging in: {e}", fg="red")
|
56
|
+
return {}
|
57
|
+
|
58
|
+
@staticmethod
|
59
|
+
def get_package_info(
|
60
|
+
name: str, version: str = "", token: Optional[str] = None
|
61
|
+
) -> dict:
|
62
|
+
"""Get action info.yaml content as json"""
|
63
|
+
endpoint = "info"
|
64
|
+
|
65
|
+
try:
|
66
|
+
headers = {"Authorization": f"Bearer {token}"} if token else None
|
67
|
+
data = {
|
68
|
+
"name": name,
|
69
|
+
"version": "" if version == "latest" else version,
|
70
|
+
}
|
71
|
+
response = requests.get(
|
72
|
+
RegistryAPI.url + endpoint, params=data, headers=headers
|
73
|
+
)
|
74
|
+
# Check if the response is successful
|
75
|
+
if response.status_code == 200:
|
76
|
+
return response.json()
|
77
|
+
else:
|
78
|
+
click.secho(
|
79
|
+
f"Error retrieving action: {response.json()['error']}",
|
80
|
+
fg="red",
|
81
|
+
)
|
82
|
+
return {}
|
83
|
+
except Exception as e:
|
84
|
+
click.secho(f"Error retrieving action: {e}", fg="red")
|
85
|
+
return {}
|
86
|
+
|
87
|
+
@staticmethod
|
88
|
+
def download_package(
|
89
|
+
name: str,
|
90
|
+
version: str = "",
|
91
|
+
info: bool = False,
|
92
|
+
suppress_error: bool = False,
|
93
|
+
token: Optional[str] = None,
|
94
|
+
) -> dict:
|
95
|
+
"""Download a Jivas Package."""
|
96
|
+
endpoint = "download"
|
97
|
+
|
98
|
+
try:
|
99
|
+
headers = {"Authorization": f"Bearer {token}"} if token else None
|
100
|
+
|
101
|
+
data = {
|
102
|
+
"name": name,
|
103
|
+
"info": "true" if info else "false",
|
104
|
+
"version": "" if version == "latest" else version,
|
105
|
+
}
|
106
|
+
response = requests.get(
|
107
|
+
RegistryAPI.url + endpoint,
|
108
|
+
params=data,
|
109
|
+
headers=headers,
|
110
|
+
)
|
111
|
+
# Check if the response is successful
|
112
|
+
if response.status_code == 200:
|
113
|
+
return response.json()
|
114
|
+
else:
|
115
|
+
if not suppress_error:
|
116
|
+
click.secho(
|
117
|
+
f"Error downloading package: {response.json()['error']}",
|
118
|
+
fg="red",
|
119
|
+
)
|
120
|
+
return {}
|
121
|
+
except Exception as e:
|
122
|
+
click.secho(f"Error downloading package: {e}", fg="red")
|
123
|
+
return {}
|
124
|
+
|
125
|
+
@staticmethod
|
126
|
+
def get_action_info(
|
127
|
+
name: str, version: str = "", token: Optional[str] = None
|
128
|
+
) -> dict:
|
129
|
+
"""Get action info.yaml content as json"""
|
130
|
+
endpoint = "info"
|
131
|
+
|
132
|
+
try:
|
133
|
+
headers = {"Authorization": f"Bearer {token}"} if token else None
|
134
|
+
data = {
|
135
|
+
"name": name,
|
136
|
+
"version": "" if version == "latest" else version,
|
137
|
+
}
|
138
|
+
response = requests.get(
|
139
|
+
RegistryAPI.url + endpoint, params=data, headers=headers
|
140
|
+
)
|
141
|
+
# Check if the response is successful
|
142
|
+
if response.status_code == 200:
|
143
|
+
return response.json()
|
144
|
+
else:
|
145
|
+
click.secho(
|
146
|
+
f"Error retrieving action: {response.json()['error']}",
|
147
|
+
fg="red",
|
148
|
+
)
|
149
|
+
return {}
|
150
|
+
except Exception as e:
|
151
|
+
click.secho(f"Error retrieving action: {e}", fg="red")
|
152
|
+
return {}
|
153
|
+
|
154
|
+
@staticmethod
|
155
|
+
def create_namespace(name: str, token: str) -> dict:
|
156
|
+
"""Create a namespace."""
|
157
|
+
endpoint = "namespace"
|
158
|
+
|
159
|
+
try:
|
160
|
+
headers = {"Authorization": f"Bearer {token}"}
|
161
|
+
|
162
|
+
data = {"name": name}
|
163
|
+
|
164
|
+
response = requests.post(
|
165
|
+
RegistryAPI.url + endpoint, headers=headers, json=data
|
166
|
+
)
|
167
|
+
# Check if the response is successful
|
168
|
+
if response.status_code == 200:
|
169
|
+
return response.json()
|
170
|
+
else:
|
171
|
+
click.secho(
|
172
|
+
f"Error creating namespace: {response.json()['message']}", fg="red"
|
173
|
+
)
|
174
|
+
return {}
|
175
|
+
except Exception as e:
|
176
|
+
click.secho(f"Error creating namespace: {e}", fg="red")
|
177
|
+
return {}
|
178
|
+
|
179
|
+
@staticmethod
|
180
|
+
def invite_user_to_namespace(
|
181
|
+
namespace_name: str, user_email: str, token: str
|
182
|
+
) -> dict:
|
183
|
+
"""Invite a user to a namespace."""
|
184
|
+
endpoint = f"namespace/{namespace_name}/invite"
|
185
|
+
|
186
|
+
try:
|
187
|
+
headers = {"Authorization": f"Bearer {token}"}
|
188
|
+
|
189
|
+
data = {"emailOrUsername": user_email}
|
190
|
+
|
191
|
+
response = requests.post(
|
192
|
+
RegistryAPI.url + endpoint, headers=headers, json=data
|
193
|
+
)
|
194
|
+
# Check if the response is successful
|
195
|
+
if response.status_code == 200:
|
196
|
+
return response.json()
|
197
|
+
else:
|
198
|
+
click.secho(
|
199
|
+
f"Error inviting user to namespace: {response.json()['message']}",
|
200
|
+
fg="red",
|
201
|
+
)
|
202
|
+
return {}
|
203
|
+
except Exception as e:
|
204
|
+
click.secho(f"Error inviting user to namespace: {e}", fg="red")
|
205
|
+
return {}
|
206
|
+
|
207
|
+
@staticmethod
|
208
|
+
def transfer_namespace_ownership(
|
209
|
+
namespace_name: str, new_owner_email: str, token: str
|
210
|
+
) -> dict:
|
211
|
+
"""Transfer ownership of a namespace."""
|
212
|
+
endpoint = f"namespace/{namespace_name}/transfer-ownership"
|
213
|
+
|
214
|
+
try:
|
215
|
+
headers = {"Authorization": f"Bearer {token}"}
|
216
|
+
|
217
|
+
data = {"emailOrUsername": new_owner_email}
|
218
|
+
|
219
|
+
response = requests.post(
|
220
|
+
RegistryAPI.url + endpoint, headers=headers, json=data
|
221
|
+
)
|
222
|
+
# Check if the response is successful
|
223
|
+
if response.status_code == 200:
|
224
|
+
return response.json()
|
225
|
+
else:
|
226
|
+
click.secho(
|
227
|
+
f"Error transferring ownership of namespace: {response.json()['message']}",
|
228
|
+
fg="red",
|
229
|
+
)
|
230
|
+
return {}
|
231
|
+
except Exception as e:
|
232
|
+
click.secho(f"Error transferring ownership of namespace: {e}", fg="red")
|
233
|
+
return {}
|
234
|
+
|
235
|
+
@staticmethod
|
236
|
+
def package_search(
|
237
|
+
query: str,
|
238
|
+
version: Optional[str] = None,
|
239
|
+
operator: Optional[str] = None,
|
240
|
+
limit: int = 15,
|
241
|
+
offset: int = 0,
|
242
|
+
) -> dict:
|
243
|
+
"""Search for packages in the Jivas Package Repository."""
|
244
|
+
endpoint = "packages/search"
|
245
|
+
|
246
|
+
try:
|
247
|
+
data = {
|
248
|
+
"q": query,
|
249
|
+
# "version": version, # TODO: Implement version filtering
|
250
|
+
# "operator": operator, # TODO: Implement operator filtering
|
251
|
+
"limit": limit,
|
252
|
+
"offset": offset,
|
253
|
+
}
|
254
|
+
response = requests.post(RegistryAPI.url + endpoint, json=data)
|
255
|
+
# Check if the response is successful
|
256
|
+
if response.status_code == 200:
|
257
|
+
return response.json()
|
258
|
+
else:
|
259
|
+
click.secho(
|
260
|
+
f"Error searching for packages: {response.json()['error']}",
|
261
|
+
fg="red",
|
262
|
+
)
|
263
|
+
return {}
|
264
|
+
except Exception as e:
|
265
|
+
click.secho(f"Error searching for packages: {e}", fg="red")
|
266
|
+
return {}
|
267
|
+
|
268
|
+
@staticmethod
|
269
|
+
def publish_action(
|
270
|
+
tgz_file_path: str, visibility: str, token: str, namespace: str
|
271
|
+
) -> dict:
|
272
|
+
"""Publish a Jivas Action to the repository."""
|
273
|
+
endpoint = "publish"
|
274
|
+
|
275
|
+
try:
|
276
|
+
headers = {
|
277
|
+
"Authorization": f"Bearer {token}",
|
278
|
+
}
|
279
|
+
|
280
|
+
# Open the .tgz file using a context manager to ensure it's closed after use
|
281
|
+
with open(tgz_file_path, "rb") as tgz_file:
|
282
|
+
files = {"file": tgz_file}
|
283
|
+
data = {
|
284
|
+
"visibility": visibility.capitalize(), # Ensure correct capitalization
|
285
|
+
"namespace": namespace,
|
286
|
+
}
|
287
|
+
|
288
|
+
# Send POST request
|
289
|
+
response = requests.post(
|
290
|
+
RegistryAPI.url + endpoint, headers=headers, files=files, data=data
|
291
|
+
)
|
292
|
+
|
293
|
+
if response.status_code == 401:
|
294
|
+
click.secho(
|
295
|
+
"Error publishing package: Invalid token. Please login again.",
|
296
|
+
fg="red",
|
297
|
+
)
|
298
|
+
return {}
|
299
|
+
|
300
|
+
# Check if the response is successful
|
301
|
+
if response.status_code == 200:
|
302
|
+
return response.json() # Return the response data if successful
|
303
|
+
else:
|
304
|
+
if response.json()["error"] == "VERSION_CONFLICT":
|
305
|
+
click.secho(
|
306
|
+
f"Error publishing package: {response.json()['message']}",
|
307
|
+
fg="red",
|
308
|
+
)
|
309
|
+
return {}
|
310
|
+
else:
|
311
|
+
# Print and show error message
|
312
|
+
click.secho(
|
313
|
+
f"Error publishing package: {response.json()}", fg="red"
|
314
|
+
)
|
315
|
+
return {}
|
316
|
+
except Exception as e:
|
317
|
+
click.secho(f"Error publishing package: {e}", fg="red")
|
318
|
+
return {}
|