cacholong-cloud-cli 0.3.3__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/PKG-INFO +73 -15
  2. cacholong_cloud_cli-1.0.0/README.md +149 -0
  3. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_cli/AsyncTyper.py +6 -3
  4. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_cli/cli.py +12 -1
  5. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/accounts.py +240 -0
  6. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/addresses.py +480 -0
  7. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/companies.py +350 -0
  8. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/dns_records.py +403 -0
  9. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/dns_templates.py +281 -0
  10. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/dns_zones.py +375 -0
  11. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/mail_address_aliases.py +351 -0
  12. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/mail_addresses.py +647 -0
  13. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/mail_domains.py +553 -0
  14. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/mail_forwards.py +328 -0
  15. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/products.py +372 -0
  16. cacholong_cloud_cli-1.0.0/cacholong_cli/commands/purchases.py +497 -0
  17. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_cli/common.py +20 -9
  18. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_cli/connection.py +4 -1
  19. cacholong_cloud_cli-1.0.0/cacholong_sdk/__init__.py +70 -0
  20. cacholong_cloud_cli-1.0.0/cacholong_sdk/account_base.py +15 -0
  21. cacholong_cloud_cli-1.0.0/cacholong_sdk/account_show.py +15 -0
  22. cacholong_cloud_cli-1.0.0/cacholong_sdk/address_base.py +15 -0
  23. cacholong_cloud_cli-1.0.0/cacholong_sdk/address_create_with_company.py +17 -0
  24. cacholong_cloud_cli-1.0.0/cacholong_sdk/address_create_with_user.py +17 -0
  25. cacholong_cloud_cli-1.0.0/cacholong_sdk/address_show.py +15 -0
  26. cacholong_cloud_cli-1.0.0/cacholong_sdk/address_update.py +15 -0
  27. cacholong_cloud_cli-1.0.0/cacholong_sdk/api_schema.py +733 -0
  28. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_sdk/common.py +76 -5
  29. cacholong_cloud_cli-1.0.0/cacholong_sdk/company_base.py +15 -0
  30. cacholong_cloud_cli-1.0.0/cacholong_sdk/company_show.py +15 -0
  31. cacholong_cloud_cli-1.0.0/cacholong_sdk/company_update.py +15 -0
  32. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_record_base.py +15 -0
  33. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_record_create_with_template.py +17 -0
  34. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_record_create_with_zone.py +17 -0
  35. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_record_show.py +15 -0
  36. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_record_update.py +15 -0
  37. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_template_base.py +15 -0
  38. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_template_create.py +15 -0
  39. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_template_show.py +15 -0
  40. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_template_update.py +15 -0
  41. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_zone_base.py +15 -0
  42. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_zone_create.py +15 -0
  43. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_zone_show.py +15 -0
  44. cacholong_cloud_cli-1.0.0/cacholong_sdk/dns_zone_update.py +15 -0
  45. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_alias_base.py +15 -0
  46. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_alias_create.py +15 -0
  47. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_alias_show.py +15 -0
  48. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_alias_update.py +15 -0
  49. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_base.py +15 -0
  50. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_create.py +15 -0
  51. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_show.py +15 -0
  52. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_address_update.py +15 -0
  53. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_domain_base.py +15 -0
  54. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_domain_show.py +15 -0
  55. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_forward_base.py +15 -0
  56. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_forward_create.py +15 -0
  57. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_forward_show.py +15 -0
  58. cacholong_cloud_cli-1.0.0/cacholong_sdk/mail_forward_update.py +15 -0
  59. cacholong_cloud_cli-1.0.0/cacholong_sdk/product_base.py +15 -0
  60. cacholong_cloud_cli-1.0.0/cacholong_sdk/product_show.py +15 -0
  61. cacholong_cloud_cli-1.0.0/cacholong_sdk/purchase_base.py +15 -0
  62. cacholong_cloud_cli-1.0.0/cacholong_sdk/purchase_show.py +15 -0
  63. cacholong_cloud_cli-1.0.0/cacholong_sdk/service_mail_base.py +15 -0
  64. cacholong_cloud_cli-1.0.0/cacholong_sdk/service_mail_show.py +15 -0
  65. cacholong_cloud_cli-1.0.0/cacholong_sdk/user_base.py +15 -0
  66. cacholong_cloud_cli-1.0.0/cacholong_sdk/user_show.py +15 -0
  67. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/pyproject.toml +3 -1
  68. cacholong_cloud_cli-0.3.3/README.md +0 -94
  69. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/accounts.py +0 -105
  70. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/addresses.py +0 -280
  71. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/companies.py +0 -100
  72. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/dns_records.py +0 -275
  73. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/dns_templates.py +0 -141
  74. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/dns_zones.py +0 -277
  75. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/products.py +0 -121
  76. cacholong_cloud_cli-0.3.3/cacholong_cli/commands/purchases.py +0 -127
  77. cacholong_cloud_cli-0.3.3/cacholong_sdk/__init__.py +0 -18
  78. cacholong_cloud_cli-0.3.3/cacholong_sdk/account.py +0 -14
  79. cacholong_cloud_cli-0.3.3/cacholong_sdk/address.py +0 -14
  80. cacholong_cloud_cli-0.3.3/cacholong_sdk/api_schema.py +0 -124
  81. cacholong_cloud_cli-0.3.3/cacholong_sdk/company.py +0 -14
  82. cacholong_cloud_cli-0.3.3/cacholong_sdk/dns_record.py +0 -14
  83. cacholong_cloud_cli-0.3.3/cacholong_sdk/dns_template.py +0 -14
  84. cacholong_cloud_cli-0.3.3/cacholong_sdk/dns_zone.py +0 -14
  85. cacholong_cloud_cli-0.3.3/cacholong_sdk/product.py +0 -14
  86. cacholong_cloud_cli-0.3.3/cacholong_sdk/purchase.py +0 -14
  87. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_cli/__init__.py +0 -0
  88. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_sdk/connection.py +0 -0
  89. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/cacholong_sdk/exception.py +0 -0
  90. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/__init__.py +0 -0
  91. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/common.py +0 -0
  92. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/document.py +0 -0
  93. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/exceptions.py +0 -0
  94. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/filter.py +0 -0
  95. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/objects.py +0 -0
  96. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/relationships.py +0 -0
  97. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/resourceobject.py +0 -0
  98. {cacholong_cloud_cli-0.3.3 → cacholong_cloud_cli-1.0.0}/jsonapi-client/src/jsonapi_client/session.py +0 -0
@@ -1,14 +1,17 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: cacholong-cloud-cli
3
- Version: 0.3.3
3
+ Version: 1.0.0
4
4
  Summary: Cacholong CLI, manage cloud environments at Cacholong!
5
+ License: MIT
5
6
  Author: Matthijs Möhlmann
6
7
  Author-email: matthijs@cacholong.nl
7
8
  Requires-Python: >=3.11,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
8
10
  Classifier: Programming Language :: Python :: 3
9
11
  Classifier: Programming Language :: Python :: 3.11
10
12
  Classifier: Programming Language :: Python :: 3.12
11
13
  Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
12
15
  Requires-Dist: aiodns (>=3.5.0,<4.0.0)
13
16
  Requires-Dist: aiofiles (>=23.2.1,<24.0.0)
14
17
  Requires-Dist: aiohttp (>=3.0)
@@ -28,6 +31,14 @@ The API client library for managing various resources.
28
31
 
29
32
  ## Getting started
30
33
 
34
+ To install this package you need to take a few steps before this works correctly
35
+ 1. Create an virtual environment: python3 -m venv <directory>
36
+ 2. Activate the environment: <directory>/bin/activate
37
+ 3. Now install the package: pip install cacholong-cloud-cli
38
+ 4. Or upgrade the package: pip install cacholong-cloud-cli --upgrade
39
+
40
+ Now you can use the command `ccloud` on the system. Please note, make sure to activate the virtual environment before running the command `ccloud`.
41
+
31
42
  You will need an API-token. This token can be created using our panel at https://cp.cacholong.eu/#/user/settings/api. You can create an api token within your profile under API.
32
43
 
33
44
  When running the command `ccloud` for the first time it will ask you for an API-token.
@@ -87,7 +98,7 @@ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
87
98
 
88
99
  async def main():
89
100
  async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
90
- searchfilter = Filter(domain=sys.argv[1])
101
+ searchfilter = Filter(account="UUID_OF_ACCOUNT")
91
102
  DnsZoneCtrl = DnsZone(api)
92
103
  async for zone in DnsZoneCtrl.fetch_all(searchfilter):
93
104
  print(zone["domain"])
@@ -96,22 +107,69 @@ async def main():
96
107
  asyncio.run(main())
97
108
  ```
98
109
 
99
- ## Suggestions for a good README
100
- 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.
110
+ ### Create a DNS-record
111
+ ```python
112
+ import asyncio
101
113
 
102
- ## Support
103
- 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.
114
+ from cacholong_sdk.connection import connection
115
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
116
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
117
+
118
+ async def main():
119
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
120
+ DnsRecordCtrl = DnsRecord(api)
121
+
122
+ dns_record = DNSRecordCtrl.create()
123
+ dns_record["dns-zone"] = ResourceTuple("UUID_DNS_ZONE", "dns-zones")
124
+ dns_record["name"] = "localhost.example.nl"
125
+ dns_record["dns_record_type"] = "A"
126
+ dns_record["content"] = "127.0.0.1"
127
+ dns_record["ttl"] = 300
128
+ await DNSRecordCtrl.store(dns_record)
129
+
130
+ # Execute main function
131
+ asyncio.run(main())
132
+ ```
133
+
134
+ ### Update a DNS-record
135
+ ```python
136
+ import asyncio
137
+
138
+ from cacholong_sdk.connection import connection
139
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
140
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
141
+
142
+ async def main():
143
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
144
+ DnsRecordCtrl = DnsRecord(api)
145
+
146
+ dns_record = await DnsRecordCtrl.fetch("UUID_OF_DNS_RECORD")
147
+ dns_record["content"] = "127.0.0.1"
148
+
149
+ # Be careful: the above change will be applied automatically
150
+
151
+ # Execute main function
152
+ asyncio.run(main())
153
+ ```
154
+
155
+ ### Delete a DNS-record
156
+ ```python
157
+ import asyncio
104
158
 
105
- ## Roadmap
106
- If you have ideas for releases in the future, it is a good idea to list them in the README.
159
+ from cacholong_sdk.connection import connection
160
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
161
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
107
162
 
108
- ## Contributing
109
- State if you are open to contributions and what your requirements are for accepting them.
163
+ async def main():
164
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
165
+ DnsRecordCtrl = DnsRecord(api)
110
166
 
111
- 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.
167
+ await DnsRecordCtrl.destroy("UUID_OF_DNS_RECORD")
112
168
 
113
- 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.
169
+ # Execute main function
170
+ asyncio.run(main())
171
+ ```
114
172
 
115
- ## License
116
- For open source projects, say how it is licensed.
173
+ ## Support
174
+ Questions, feedback, or suggestions? Send us an email at [ccloud-support@cacholong.nl].
117
175
 
@@ -0,0 +1,149 @@
1
+ # CLI frontend
2
+
3
+ The API client library for managing various resources.
4
+
5
+ [Client Library Documentation](https://docs.cacholong.eu/api/)
6
+
7
+ ## Getting started
8
+
9
+ To install this package you need to take a few steps before this works correctly
10
+ 1. Create an virtual environment: python3 -m venv <directory>
11
+ 2. Activate the environment: <directory>/bin/activate
12
+ 3. Now install the package: pip install cacholong-cloud-cli
13
+ 4. Or upgrade the package: pip install cacholong-cloud-cli --upgrade
14
+
15
+ Now you can use the command `ccloud` on the system. Please note, make sure to activate the virtual environment before running the command `ccloud`.
16
+
17
+ You will need an API-token. This token can be created using our panel at https://cp.cacholong.eu/#/user/settings/api. You can create an api token within your profile under API.
18
+
19
+ When running the command `ccloud` for the first time it will ask you for an API-token.
20
+
21
+ After that you will be able to run the following command:
22
+ ```bash
23
+ ccloud accounts list
24
+ ```
25
+
26
+ This will give you an overview of accounts where you have access to.
27
+
28
+ ## Usage
29
+
30
+ Overview of the possibilities:
31
+ ```bash
32
+ ccloud --help
33
+ ```
34
+
35
+ To fetch an overview of the dns-zones for an account:
36
+ ```bash
37
+ ccloud dns-zones list --account <account uuid>
38
+ ```
39
+
40
+ Creating a DNS-record:
41
+ ```bash
42
+ ccloud dns-records create --dns-zone <dns-zone uuid> \
43
+ --name localhost.example.com \
44
+ --dns-record-type A \
45
+ --content 127.0.0.1 \
46
+ --ttl 300
47
+ ```
48
+
49
+ Updating a DNS-record:
50
+ ```bash
51
+ ccloud dns-records update <dns-record uuid> \
52
+ --content 127.0.0.1
53
+ ```
54
+
55
+ Deleting a DNS-record:
56
+ ```bash
57
+ ccloud dns-records delete <dns-record uuid>
58
+ ```
59
+
60
+ Every command includes an option --help which will give an overview of the possibilities.
61
+
62
+ ## Advanced usage
63
+
64
+ Its also possible to create your own command line utility to handle various parts. Here are the same examples as above but now using python.
65
+
66
+ ### Fetching DNS-zones
67
+ ```python
68
+ import asyncio
69
+
70
+ from cacholong_sdk.connection import connection
71
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
72
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
73
+
74
+ async def main():
75
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
76
+ searchfilter = Filter(account="UUID_OF_ACCOUNT")
77
+ DnsZoneCtrl = DnsZone(api)
78
+ async for zone in DnsZoneCtrl.fetch_all(searchfilter):
79
+ print(zone["domain"])
80
+
81
+ # Execute main function
82
+ asyncio.run(main())
83
+ ```
84
+
85
+ ### Create a DNS-record
86
+ ```python
87
+ import asyncio
88
+
89
+ from cacholong_sdk.connection import connection
90
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
91
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
92
+
93
+ async def main():
94
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
95
+ DnsRecordCtrl = DnsRecord(api)
96
+
97
+ dns_record = DNSRecordCtrl.create()
98
+ dns_record["dns-zone"] = ResourceTuple("UUID_DNS_ZONE", "dns-zones")
99
+ dns_record["name"] = "localhost.example.nl"
100
+ dns_record["dns_record_type"] = "A"
101
+ dns_record["content"] = "127.0.0.1"
102
+ dns_record["ttl"] = 300
103
+ await DNSRecordCtrl.store(dns_record)
104
+
105
+ # Execute main function
106
+ asyncio.run(main())
107
+ ```
108
+
109
+ ### Update a DNS-record
110
+ ```python
111
+ import asyncio
112
+
113
+ from cacholong_sdk.connection import connection
114
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
115
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
116
+
117
+ async def main():
118
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
119
+ DnsRecordCtrl = DnsRecord(api)
120
+
121
+ dns_record = await DnsRecordCtrl.fetch("UUID_OF_DNS_RECORD")
122
+ dns_record["content"] = "127.0.0.1"
123
+
124
+ # Be careful: the above change will be applied automatically
125
+
126
+ # Execute main function
127
+ asyncio.run(main())
128
+ ```
129
+
130
+ ### Delete a DNS-record
131
+ ```python
132
+ import asyncio
133
+
134
+ from cacholong_sdk.connection import connection
135
+ from cacholong_sdk import ResourceTuple, Inclusion, Filter
136
+ from cacholong_sdk import DnsZone, DnsZoneModel, DnsRecord, DnsRecordModel
137
+
138
+ async def main():
139
+ async with connection('https://api.cacholong.eu/api/v1/', 'YOUR-API-TOKEN') as api:
140
+ DnsRecordCtrl = DnsRecord(api)
141
+
142
+ await DnsRecordCtrl.destroy("UUID_OF_DNS_RECORD")
143
+
144
+ # Execute main function
145
+ asyncio.run(main())
146
+ ```
147
+
148
+ ## Support
149
+ Questions, feedback, or suggestions? Send us an email at [ccloud-support@cacholong.nl].
@@ -1,14 +1,17 @@
1
1
  from asyncio import run
2
2
  from functools import wraps
3
+ from typing import Callable, Any
3
4
 
4
5
  import typer
5
6
 
6
7
 
7
8
  class AsyncTyper(typer.Typer):
8
- def async_command(self, *args, **kwargs):
9
- def decorator(async_func):
9
+ def async_command(
10
+ self, *args: Any, **kwargs: Any
11
+ ) -> Callable[[Callable], Callable]:
12
+ def decorator(async_func: Callable) -> Callable:
10
13
  @wraps(async_func)
11
- def sync_func(*_args, **_kwargs):
14
+ def sync_func(*_args: Any, **_kwargs: Any) -> Any:
12
15
  return run(async_func(*_args, **_kwargs))
13
16
 
14
17
  self.command(*args, **kwargs)(sync_func)
@@ -11,13 +11,16 @@ from cacholong_cli.commands import (
11
11
  dns_records,
12
12
  dns_templates,
13
13
  dns_zones,
14
+ mail_addresses,
15
+ mail_address_aliases,
16
+ mail_domains,
17
+ mail_forwards,
14
18
  products,
15
19
  purchases,
16
20
  )
17
21
  from cacholong_cli.common import OutputFormat
18
22
  from xdg import BaseDirectory
19
23
 
20
-
21
24
  # Version of our CLI
22
25
  __version__ = importlib.metadata.version("cacholong-cloud-cli")
23
26
 
@@ -44,6 +47,14 @@ app.add_typer(companies.app, name="companies", help="Manage companies")
44
47
  app.add_typer(dns_records.app, name="dns-records", help="Manage DNS records")
45
48
  app.add_typer(dns_templates.app, name="dns-templates", help="Manage DNS templates")
46
49
  app.add_typer(dns_zones.app, name="dns-zones", help="Manage DNS zones")
50
+ app.add_typer(mail_addresses.app, name="mail-addresses", help="Manage mail addresses")
51
+ app.add_typer(
52
+ mail_address_aliases.app,
53
+ name="mail-address-aliases",
54
+ help="Manage mail address aliases",
55
+ )
56
+ app.add_typer(mail_domains.app, name="mail-domains", help="Manage mail domains")
57
+ app.add_typer(mail_forwards.app, name="mail-forwards", help="Manage mail forwards")
47
58
  app.add_typer(products.app, name="products", help="Manage products")
48
59
  app.add_typer(purchases.app, name="purchases", help="Manage purchases")
49
60
 
@@ -0,0 +1,240 @@
1
+ import asyncio
2
+ import typer
3
+ from typing import List, Optional, Dict, Any, Union, Type
4
+ from typing_extensions import Annotated
5
+ from rich.table import Column
6
+ from uuid import UUID
7
+ from datetime import datetime, date, timezone
8
+ from cacholong_cli.AsyncTyper import AsyncTyper
9
+ from cacholong_cli.common import (
10
+ list_resources,
11
+ list_relation_resources,
12
+ show_resource,
13
+ print_document_error,
14
+ TableDef,
15
+ )
16
+ from cacholong_cli.connection import Connection
17
+ from cacholong_sdk import Filter, Inclusion, DocumentError, ResourceTuple
18
+ from cacholong_sdk import AccountBase, AccountBaseModel
19
+
20
+ from cacholong_sdk.api_schema import api_schema
21
+
22
+ # Create typer object
23
+ app = AsyncTyper()
24
+
25
+
26
+ @app.async_command(help="Get accounts")
27
+ async def list(
28
+ ctx: typer.Context,
29
+ name: Annotated[Optional[str], typer.Option(help="The unique account name")] = None,
30
+ description: Annotated[
31
+ Optional[str], typer.Option(help="Optional description of the account")
32
+ ] = None,
33
+ account_type: Annotated[
34
+ Optional[str], typer.Option(help="The account type")
35
+ ] = None,
36
+ account_account_id: Annotated[
37
+ Optional[str], typer.Option(help="Parent account ID")
38
+ ] = None,
39
+ account_account_relation: Annotated[
40
+ Optional[str], typer.Option(help="Parent account relationship type")
41
+ ] = None,
42
+ created_at: Annotated[
43
+ Optional[datetime],
44
+ typer.Option(help="Timestamp when the account was created (exact match)"),
45
+ ] = None,
46
+ created_at_gte: Annotated[
47
+ Optional[datetime],
48
+ typer.Option(
49
+ help="Timestamp when the account was created (greater than or equal)"
50
+ ),
51
+ ] = None,
52
+ created_at_lte: Annotated[
53
+ Optional[datetime],
54
+ typer.Option(
55
+ help="Timestamp when the account was created (less than or equal)"
56
+ ),
57
+ ] = None,
58
+ created_at_gt: Annotated[
59
+ Optional[datetime],
60
+ typer.Option(help="Timestamp when the account was created (greater than)"),
61
+ ] = None,
62
+ created_at_lt: Annotated[
63
+ Optional[datetime],
64
+ typer.Option(help="Timestamp when the account was created (less than)"),
65
+ ] = None,
66
+ updated_at: Annotated[
67
+ Optional[datetime],
68
+ typer.Option(help="Timestamp when the account was last updated (exact match)"),
69
+ ] = None,
70
+ updated_at_gte: Annotated[
71
+ Optional[datetime],
72
+ typer.Option(
73
+ help="Timestamp when the account was last updated (greater than or equal)"
74
+ ),
75
+ ] = None,
76
+ updated_at_lte: Annotated[
77
+ Optional[datetime],
78
+ typer.Option(
79
+ help="Timestamp when the account was last updated (less than or equal)"
80
+ ),
81
+ ] = None,
82
+ updated_at_gt: Annotated[
83
+ Optional[datetime],
84
+ typer.Option(help="Timestamp when the account was last updated (greater than)"),
85
+ ] = None,
86
+ updated_at_lt: Annotated[
87
+ Optional[datetime],
88
+ typer.Option(help="Timestamp when the account was last updated (less than)"),
89
+ ] = None,
90
+ company: Annotated[
91
+ Optional[UUID], typer.Option(help="The company associated with this account")
92
+ ] = None,
93
+ ):
94
+
95
+ # Build modifier
96
+ modifier = []
97
+ if name is not None:
98
+ modifier.append(Filter(name=name))
99
+ if description is not None:
100
+ modifier.append(Filter(description=description))
101
+ if account_type is not None:
102
+ modifier.append(Filter(query_str="filter[account_type]=" + str(account_type)))
103
+ if account_account_id is not None:
104
+ modifier.append(
105
+ Filter(query_str="filter[account_account_id]=" + str(account_account_id))
106
+ )
107
+ if account_account_relation is not None:
108
+ modifier.append(
109
+ Filter(
110
+ query_str="filter[account_account_relation]="
111
+ + str(account_account_relation)
112
+ )
113
+ )
114
+ if created_at is not None:
115
+ modifier.append(
116
+ Filter(
117
+ query_str="filter[created_at]="
118
+ + created_at.astimezone(timezone.utc)
119
+ .replace(tzinfo=None)
120
+ .isoformat(timespec="milliseconds")
121
+ + "Z"
122
+ )
123
+ )
124
+ if created_at_gte is not None:
125
+ modifier.append(
126
+ Filter(
127
+ query_str="filter[created_at_gte]="
128
+ + created_at_gte.astimezone(timezone.utc)
129
+ .replace(tzinfo=None)
130
+ .isoformat(timespec="milliseconds")
131
+ + "Z"
132
+ )
133
+ )
134
+ if created_at_lte is not None:
135
+ modifier.append(
136
+ Filter(
137
+ query_str="filter[created_at_lte]="
138
+ + created_at_lte.astimezone(timezone.utc)
139
+ .replace(tzinfo=None)
140
+ .isoformat(timespec="milliseconds")
141
+ + "Z"
142
+ )
143
+ )
144
+ if created_at_gt is not None:
145
+ modifier.append(
146
+ Filter(
147
+ query_str="filter[created_at_gt]="
148
+ + created_at_gt.astimezone(timezone.utc)
149
+ .replace(tzinfo=None)
150
+ .isoformat(timespec="milliseconds")
151
+ + "Z"
152
+ )
153
+ )
154
+ if created_at_lt is not None:
155
+ modifier.append(
156
+ Filter(
157
+ query_str="filter[created_at_lt]="
158
+ + created_at_lt.astimezone(timezone.utc)
159
+ .replace(tzinfo=None)
160
+ .isoformat(timespec="milliseconds")
161
+ + "Z"
162
+ )
163
+ )
164
+ if updated_at is not None:
165
+ modifier.append(
166
+ Filter(
167
+ query_str="filter[updated_at]="
168
+ + updated_at.astimezone(timezone.utc)
169
+ .replace(tzinfo=None)
170
+ .isoformat(timespec="milliseconds")
171
+ + "Z"
172
+ )
173
+ )
174
+ if updated_at_gte is not None:
175
+ modifier.append(
176
+ Filter(
177
+ query_str="filter[updated_at_gte]="
178
+ + updated_at_gte.astimezone(timezone.utc)
179
+ .replace(tzinfo=None)
180
+ .isoformat(timespec="milliseconds")
181
+ + "Z"
182
+ )
183
+ )
184
+ if updated_at_lte is not None:
185
+ modifier.append(
186
+ Filter(
187
+ query_str="filter[updated_at_lte]="
188
+ + updated_at_lte.astimezone(timezone.utc)
189
+ .replace(tzinfo=None)
190
+ .isoformat(timespec="milliseconds")
191
+ + "Z"
192
+ )
193
+ )
194
+ if updated_at_gt is not None:
195
+ modifier.append(
196
+ Filter(
197
+ query_str="filter[updated_at_gt]="
198
+ + updated_at_gt.astimezone(timezone.utc)
199
+ .replace(tzinfo=None)
200
+ .isoformat(timespec="milliseconds")
201
+ + "Z"
202
+ )
203
+ )
204
+ if updated_at_lt is not None:
205
+ modifier.append(
206
+ Filter(
207
+ query_str="filter[updated_at_lt]="
208
+ + updated_at_lt.astimezone(timezone.utc)
209
+ .replace(tzinfo=None)
210
+ .isoformat(timespec="milliseconds")
211
+ + "Z"
212
+ )
213
+ )
214
+ if company is not None:
215
+ modifier.append(Filter(company=str(company)))
216
+
217
+ # Table definition
218
+ tabledef: TableDef = [
219
+ {"header": Column("Id", no_wrap=True), "column": "id"},
220
+ {"header": "Created", "column": "created_at"},
221
+ {"header": "Updated", "column": "updated_at"},
222
+ ]
223
+ async with Connection() as conn:
224
+ await list_resources(ctx, AccountBase(conn, api_schema), tabledef, modifier)
225
+
226
+
227
+ @app.async_command(help="Get account with account id")
228
+ async def show(
229
+ ctx: typer.Context,
230
+ account_id: Annotated[UUID, typer.Argument(help="Resource ID to show")],
231
+ ):
232
+ # Show resource
233
+ try:
234
+ async with Connection() as conn:
235
+ ctrl = AccountBase(conn, api_schema)
236
+ model = await ctrl.fetch(account_id)
237
+
238
+ show_resource(ctx, model)
239
+ except DocumentError as e:
240
+ await print_document_error(e)