cacholong-cloud-cli 0.3.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.
- cacholong_cloud_cli-0.3.0/PKG-INFO +115 -0
- cacholong_cloud_cli-0.3.0/README.md +92 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/AsyncTyper.py +17 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/__init__.py +0 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/cli.py +110 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/accounts.py +105 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/addresses.py +280 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/companies.py +100 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/dns_records.py +275 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/dns_templates.py +141 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/dns_zones.py +277 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/products.py +121 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/commands/purchases.py +127 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/common.py +179 -0
- cacholong_cloud_cli-0.3.0/cacholong_cli/connection.py +18 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/__init__.py +18 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/account.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/address.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/api_schema.py +124 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/common.py +119 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/company.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/connection.py +22 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/dns_record.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/dns_template.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/dns_zone.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/exception.py +7 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/product.py +14 -0
- cacholong_cloud_cli-0.3.0/cacholong_sdk/purchase.py +14 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/__init__.py +42 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/common.py +186 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/document.py +161 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/exceptions.py +62 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/filter.py +155 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/objects.py +187 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/relationships.py +447 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/resourceobject.py +656 -0
- cacholong_cloud_cli-0.3.0/jsonapi-client/src/jsonapi_client/session.py +755 -0
- cacholong_cloud_cli-0.3.0/pyproject.toml +37 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: cacholong-cloud-cli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Cacholong CLI, manage cloud environments at Cacholong!
|
|
5
|
+
Author: Matthijs Möhlmann
|
|
6
|
+
Author-email: matthijs@cacholong.nl
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: aiodns (>=3.5.0,<4.0.0)
|
|
13
|
+
Requires-Dist: aiofiles (>=23.2.1,<24.0.0)
|
|
14
|
+
Requires-Dist: aiohttp (>=3.0)
|
|
15
|
+
Requires-Dist: jsonschema (>=4.25.1,<5.0.0)
|
|
16
|
+
Requires-Dist: pyxdg
|
|
17
|
+
Requires-Dist: requests (>=2.32.5,<3.0.0)
|
|
18
|
+
Requires-Dist: rich
|
|
19
|
+
Requires-Dist: typer
|
|
20
|
+
Requires-Dist: types-aiofiles (>=23.2.0.20240403,<24.0.0.0)
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# CLI frontend
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Getting started
|
|
28
|
+
|
|
29
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
30
|
+
|
|
31
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
32
|
+
|
|
33
|
+
## Add your files
|
|
34
|
+
|
|
35
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
36
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
cd existing_repo
|
|
40
|
+
git remote add origin https://gitlab.cacholong.nl/cacholong/cli-frontend.git
|
|
41
|
+
git branch -M main
|
|
42
|
+
git push -uf origin main
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Integrate with your tools
|
|
46
|
+
|
|
47
|
+
- [ ] [Set up project integrations](https://gitlab.cacholong.nl/cacholong/cli-frontend/-/settings/integrations)
|
|
48
|
+
|
|
49
|
+
## Collaborate with your team
|
|
50
|
+
|
|
51
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
52
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
53
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
54
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
55
|
+
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
56
|
+
|
|
57
|
+
## Test and Deploy
|
|
58
|
+
|
|
59
|
+
Use the built-in continuous integration in GitLab.
|
|
60
|
+
|
|
61
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
62
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
63
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
64
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
65
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
69
|
+
# Editing this README
|
|
70
|
+
|
|
71
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
72
|
+
|
|
73
|
+
## Suggestions for a good README
|
|
74
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
75
|
+
|
|
76
|
+
## Name
|
|
77
|
+
Choose a self-explaining name for your project.
|
|
78
|
+
|
|
79
|
+
## Description
|
|
80
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
81
|
+
|
|
82
|
+
## Badges
|
|
83
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
84
|
+
|
|
85
|
+
## Visuals
|
|
86
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
87
|
+
|
|
88
|
+
## Installation
|
|
89
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
93
|
+
|
|
94
|
+
## Support
|
|
95
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
96
|
+
|
|
97
|
+
## Roadmap
|
|
98
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
99
|
+
|
|
100
|
+
## Contributing
|
|
101
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
102
|
+
|
|
103
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
104
|
+
|
|
105
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
106
|
+
|
|
107
|
+
## Authors and acknowledgment
|
|
108
|
+
Show your appreciation to those who have contributed to the project.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
For open source projects, say how it is licensed.
|
|
112
|
+
|
|
113
|
+
## Project status
|
|
114
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
115
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# CLI frontend
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.cacholong.nl/cacholong/cli-frontend.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://gitlab.cacholong.nl/cacholong/cli-frontend/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
53
|
+
|
|
54
|
+
## Name
|
|
55
|
+
Choose a self-explaining name for your project.
|
|
56
|
+
|
|
57
|
+
## Description
|
|
58
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
59
|
+
|
|
60
|
+
## Badges
|
|
61
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
62
|
+
|
|
63
|
+
## Visuals
|
|
64
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
71
|
+
|
|
72
|
+
## Support
|
|
73
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
74
|
+
|
|
75
|
+
## Roadmap
|
|
76
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
77
|
+
|
|
78
|
+
## Contributing
|
|
79
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
80
|
+
|
|
81
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
82
|
+
|
|
83
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
84
|
+
|
|
85
|
+
## Authors and acknowledgment
|
|
86
|
+
Show your appreciation to those who have contributed to the project.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
For open source projects, say how it is licensed.
|
|
90
|
+
|
|
91
|
+
## Project status
|
|
92
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from asyncio import run
|
|
2
|
+
from functools import wraps
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AsyncTyper(typer.Typer):
|
|
8
|
+
def async_command(self, *args, **kwargs):
|
|
9
|
+
def decorator(async_func):
|
|
10
|
+
@wraps(async_func)
|
|
11
|
+
def sync_func(*_args, **_kwargs):
|
|
12
|
+
return run(async_func(*_args, **_kwargs))
|
|
13
|
+
|
|
14
|
+
self.command(*args, **kwargs)(sync_func)
|
|
15
|
+
return async_func
|
|
16
|
+
|
|
17
|
+
return decorator
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import importlib.metadata
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import typer
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from cacholong_cli.commands import (
|
|
8
|
+
accounts,
|
|
9
|
+
addresses,
|
|
10
|
+
companies,
|
|
11
|
+
dns_records,
|
|
12
|
+
dns_templates,
|
|
13
|
+
dns_zones,
|
|
14
|
+
products,
|
|
15
|
+
purchases,
|
|
16
|
+
)
|
|
17
|
+
from cacholong_cli.common import OutputFormat
|
|
18
|
+
from xdg import BaseDirectory
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Version of our CLI
|
|
22
|
+
__version__ = importlib.metadata.version("cacholong-cloud-cli")
|
|
23
|
+
|
|
24
|
+
# Check if required config.ini file exists
|
|
25
|
+
configpath = BaseDirectory.save_config_path("cacholong-cli")
|
|
26
|
+
if not os.path.exists(os.path.join(configpath, "config.ini")):
|
|
27
|
+
print("Get a token through our panel at https://cp.cacholong.eu/")
|
|
28
|
+
token = input("API Token: ")
|
|
29
|
+
if len(token) == 0:
|
|
30
|
+
print("Invalid token")
|
|
31
|
+
sys.exit(1)
|
|
32
|
+
with open(os.path.join(configpath, "config.ini"), "w") as f:
|
|
33
|
+
f.write("[DEFAULT]\n")
|
|
34
|
+
f.write("api_url = 'https://api.cacholong.eu/api/v1/'\n")
|
|
35
|
+
f.write("api_key = '" + token + "'\n")
|
|
36
|
+
|
|
37
|
+
# Generate the available commands
|
|
38
|
+
app = typer.Typer()
|
|
39
|
+
app.add_typer(accounts.app, name="accounts", help="Manage accounts")
|
|
40
|
+
app.add_typer(
|
|
41
|
+
addresses.app, name="addresses", help="Manage addresses for users and companies"
|
|
42
|
+
)
|
|
43
|
+
app.add_typer(companies.app, name="companies", help="Manage companies")
|
|
44
|
+
app.add_typer(dns_records.app, name="dns-records", help="Manage DNS records")
|
|
45
|
+
app.add_typer(dns_templates.app, name="dns-templates", help="Manage DNS templates")
|
|
46
|
+
app.add_typer(dns_zones.app, name="dns-zones", help="Manage DNS zones")
|
|
47
|
+
app.add_typer(products.app, name="products", help="Manage products")
|
|
48
|
+
app.add_typer(purchases.app, name="purchases", help="Manage purchases")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Handle version
|
|
52
|
+
def _version_callback(value: bool) -> None:
|
|
53
|
+
if value:
|
|
54
|
+
typer.echo(f"cacholong cli version: {__version__}")
|
|
55
|
+
raise typer.Exit()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _verbose_callback(ctx: typer.Context, value: bool) -> None:
|
|
59
|
+
ctx.obj["verbose"] = False
|
|
60
|
+
if value:
|
|
61
|
+
ctx.obj["verbose"] = True
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _output_callback(ctx: typer.Context, value: OutputFormat) -> None:
|
|
65
|
+
ctx.obj["output"] = value
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _create_issue_callback(ctx: typer.Context, value: bool) -> None:
|
|
69
|
+
ctx.obj["create_issue"] = value
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _sync_callback(ctx: typer.Context, value: bool) -> None:
|
|
73
|
+
ctx.obj["sync"] = value
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _sort_callback(ctx: typer.Context, value: str) -> None:
|
|
77
|
+
ctx.obj["sort"] = value
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@app.callback(context_settings={"obj": {}})
|
|
81
|
+
def main(
|
|
82
|
+
ctx: typer.Context,
|
|
83
|
+
version: Optional[bool] = typer.Option(
|
|
84
|
+
None,
|
|
85
|
+
"--version",
|
|
86
|
+
help="Show the application's version and exit.",
|
|
87
|
+
callback=_version_callback,
|
|
88
|
+
is_eager=True,
|
|
89
|
+
),
|
|
90
|
+
verbose: Optional[bool] = typer.Option(
|
|
91
|
+
None, "--verbose", help="Verbose output", callback=_verbose_callback
|
|
92
|
+
),
|
|
93
|
+
sort: Optional[str] = typer.Option(
|
|
94
|
+
"-created_at", "--sort", help="Field to sort on", callback=_sort_callback
|
|
95
|
+
),
|
|
96
|
+
create_issue: bool = typer.Option(
|
|
97
|
+
False,
|
|
98
|
+
"--create-issue",
|
|
99
|
+
help="Create an issue in gitlab",
|
|
100
|
+
callback=_create_issue_callback,
|
|
101
|
+
),
|
|
102
|
+
sync: bool = typer.Option(
|
|
103
|
+
False, "--sync", help="Process action directly", callback=_sync_callback
|
|
104
|
+
),
|
|
105
|
+
output: OutputFormat = typer.Option(
|
|
106
|
+
"table", "--output", help="Output format", callback=_output_callback
|
|
107
|
+
),
|
|
108
|
+
) -> None:
|
|
109
|
+
|
|
110
|
+
return
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import typer
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from typing_extensions import Annotated
|
|
5
|
+
from rich.table import Column
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
from cacholong_cli.AsyncTyper import AsyncTyper
|
|
8
|
+
from cacholong_cli.common import (
|
|
9
|
+
list_resources,
|
|
10
|
+
list_relation_resources,
|
|
11
|
+
show_resource,
|
|
12
|
+
print_document_error,
|
|
13
|
+
)
|
|
14
|
+
from cacholong_cli.connection import Connection
|
|
15
|
+
from cacholong_sdk import Filter, Inclusion, DocumentError, ResourceTuple
|
|
16
|
+
from cacholong_sdk import Account, AccountModel
|
|
17
|
+
|
|
18
|
+
# Create typer object
|
|
19
|
+
app = AsyncTyper()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.async_command()
|
|
23
|
+
async def list(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
name: Annotated[
|
|
26
|
+
Optional[str],
|
|
27
|
+
typer.Option(
|
|
28
|
+
help="Must be unique. Can contain any letter (combined with accent) from any language, any kind of hyphen or dash, single or alternative quote, numbers 0 to 9, space or the following symbols: @ & + - ( ) ? ! * # /"
|
|
29
|
+
),
|
|
30
|
+
] = None,
|
|
31
|
+
display_name: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
32
|
+
description: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
33
|
+
created_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
34
|
+
updated_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
35
|
+
account_type: Annotated[
|
|
36
|
+
Optional[str], typer.Option(help="Only available for certain users.")
|
|
37
|
+
] = None,
|
|
38
|
+
account_account_id: Annotated[
|
|
39
|
+
Optional[str],
|
|
40
|
+
typer.Option(
|
|
41
|
+
help="Only available for certain users. When used, account_account_relation is mandatory."
|
|
42
|
+
),
|
|
43
|
+
] = None,
|
|
44
|
+
account_account_relation: Annotated[
|
|
45
|
+
Optional[str],
|
|
46
|
+
typer.Option(
|
|
47
|
+
help="Only available for certain users. When used, account_account_id is mandatory."
|
|
48
|
+
),
|
|
49
|
+
] = None,
|
|
50
|
+
company: Annotated[Optional[UUID], typer.Option(help="")] = None,
|
|
51
|
+
):
|
|
52
|
+
# Build modifier
|
|
53
|
+
modifier = []
|
|
54
|
+
if name is not None:
|
|
55
|
+
modifier.append(Filter(name=name))
|
|
56
|
+
if display_name is not None:
|
|
57
|
+
modifier.append(Filter(query_str="filter[display_name]=" + str(display_name)))
|
|
58
|
+
if description is not None:
|
|
59
|
+
modifier.append(Filter(description=description))
|
|
60
|
+
if created_at is not None:
|
|
61
|
+
modifier.append(Filter(query_str="filter[created_at]=" + str(created_at)))
|
|
62
|
+
if updated_at is not None:
|
|
63
|
+
modifier.append(Filter(query_str="filter[updated_at]=" + str(updated_at)))
|
|
64
|
+
if account_type is not None:
|
|
65
|
+
modifier.append(Filter(query_str="filter[account_type]=" + str(account_type)))
|
|
66
|
+
if account_account_id is not None:
|
|
67
|
+
modifier.append(
|
|
68
|
+
Filter(query_str="filter[account_account_id]=" + str(account_account_id))
|
|
69
|
+
)
|
|
70
|
+
if account_account_relation is not None:
|
|
71
|
+
modifier.append(
|
|
72
|
+
Filter(
|
|
73
|
+
query_str="filter[account_account_relation]="
|
|
74
|
+
+ str(account_account_relation)
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
if company is not None:
|
|
78
|
+
modifier.append(Filter(company=str(company)))
|
|
79
|
+
|
|
80
|
+
# Table definition
|
|
81
|
+
tabledef = [
|
|
82
|
+
{"header": Column("Id", no_wrap=True), "column": "id"},
|
|
83
|
+
{"header": "Name", "column": "name"},
|
|
84
|
+
{"header": "Display name", "column": "display_name"},
|
|
85
|
+
{"header": "Created", "column": "created_at"},
|
|
86
|
+
{"header": "Updated", "column": "updated_at"},
|
|
87
|
+
]
|
|
88
|
+
async with Connection() as conn:
|
|
89
|
+
await list_resources(ctx, Account(conn), tabledef, modifier)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@app.async_command()
|
|
93
|
+
async def show(
|
|
94
|
+
ctx: typer.Context,
|
|
95
|
+
account_id: Annotated[UUID, typer.Argument()],
|
|
96
|
+
):
|
|
97
|
+
# Show resource
|
|
98
|
+
try:
|
|
99
|
+
async with Connection() as conn:
|
|
100
|
+
ctrl = Account(conn)
|
|
101
|
+
model = await ctrl.fetch(account_id)
|
|
102
|
+
|
|
103
|
+
show_resource(ctx, model)
|
|
104
|
+
except DocumentError as e:
|
|
105
|
+
await print_document_error(e)
|