cacholong-cloud-cli 0.3.0__py3-none-any.whl
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_cli/AsyncTyper.py +17 -0
- cacholong_cli/__init__.py +0 -0
- cacholong_cli/cli.py +110 -0
- cacholong_cli/commands/accounts.py +105 -0
- cacholong_cli/commands/addresses.py +280 -0
- cacholong_cli/commands/companies.py +100 -0
- cacholong_cli/commands/dns_records.py +275 -0
- cacholong_cli/commands/dns_templates.py +141 -0
- cacholong_cli/commands/dns_zones.py +277 -0
- cacholong_cli/commands/products.py +121 -0
- cacholong_cli/commands/purchases.py +127 -0
- cacholong_cli/common.py +179 -0
- cacholong_cli/connection.py +18 -0
- cacholong_cloud_cli-0.3.0.dist-info/METADATA +115 -0
- cacholong_cloud_cli-0.3.0.dist-info/RECORD +39 -0
- cacholong_cloud_cli-0.3.0.dist-info/WHEEL +4 -0
- cacholong_cloud_cli-0.3.0.dist-info/entry_points.txt +3 -0
- cacholong_sdk/__init__.py +18 -0
- cacholong_sdk/account.py +14 -0
- cacholong_sdk/address.py +14 -0
- cacholong_sdk/api_schema.py +124 -0
- cacholong_sdk/common.py +119 -0
- cacholong_sdk/company.py +14 -0
- cacholong_sdk/connection.py +22 -0
- cacholong_sdk/dns_record.py +14 -0
- cacholong_sdk/dns_template.py +14 -0
- cacholong_sdk/dns_zone.py +14 -0
- cacholong_sdk/exception.py +7 -0
- cacholong_sdk/product.py +14 -0
- cacholong_sdk/purchase.py +14 -0
- jsonapi_client/__init__.py +42 -0
- jsonapi_client/common.py +186 -0
- jsonapi_client/document.py +161 -0
- jsonapi_client/exceptions.py +62 -0
- jsonapi_client/filter.py +155 -0
- jsonapi_client/objects.py +187 -0
- jsonapi_client/relationships.py +447 -0
- jsonapi_client/resourceobject.py +656 -0
- jsonapi_client/session.py +755 -0
|
@@ -0,0 +1,121 @@
|
|
|
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 Product, ProductModel
|
|
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="Can contain any letter (combined with accent) from any language, any kind of hyphen or dash, numbers 0 to 9, space or point."
|
|
29
|
+
),
|
|
30
|
+
] = None,
|
|
31
|
+
product_type: Annotated[
|
|
32
|
+
Optional[str],
|
|
33
|
+
typer.Option(
|
|
34
|
+
help='Please note that "option" is only available for child products.'
|
|
35
|
+
),
|
|
36
|
+
] = None,
|
|
37
|
+
price: Annotated[
|
|
38
|
+
Optional[str],
|
|
39
|
+
typer.Option(
|
|
40
|
+
help="Allows the use of both a comma and a period as decimal separator."
|
|
41
|
+
),
|
|
42
|
+
] = None,
|
|
43
|
+
default_bill_sequence: Annotated[
|
|
44
|
+
Optional[str],
|
|
45
|
+
typer.Option(help="Only available for products with product_type management."),
|
|
46
|
+
] = None,
|
|
47
|
+
invoice_description: Annotated[
|
|
48
|
+
Optional[str], typer.Option(help="Default description for the invoice item.")
|
|
49
|
+
] = None,
|
|
50
|
+
publish_start: Annotated[
|
|
51
|
+
Optional[str], typer.Option(help="Start date of the product.")
|
|
52
|
+
] = None,
|
|
53
|
+
publish_end: Annotated[
|
|
54
|
+
Optional[str], typer.Option(help="End date of the product.")
|
|
55
|
+
] = None,
|
|
56
|
+
created_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
57
|
+
updated_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
58
|
+
parent: Annotated[
|
|
59
|
+
Optional[UUID],
|
|
60
|
+
typer.Option(
|
|
61
|
+
help="If product has parent, existing parent product. Readonly on update."
|
|
62
|
+
),
|
|
63
|
+
] = None,
|
|
64
|
+
):
|
|
65
|
+
# Build modifier
|
|
66
|
+
modifier = []
|
|
67
|
+
if name is not None:
|
|
68
|
+
modifier.append(Filter(name=name))
|
|
69
|
+
if product_type is not None:
|
|
70
|
+
modifier.append(Filter(query_str="filter[product_type]=" + str(product_type)))
|
|
71
|
+
if price is not None:
|
|
72
|
+
modifier.append(Filter(price=price))
|
|
73
|
+
if default_bill_sequence is not None:
|
|
74
|
+
modifier.append(
|
|
75
|
+
Filter(
|
|
76
|
+
query_str="filter[default_bill_sequence]=" + str(default_bill_sequence)
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
if invoice_description is not None:
|
|
80
|
+
modifier.append(
|
|
81
|
+
Filter(query_str="filter[invoice_description]=" + str(invoice_description))
|
|
82
|
+
)
|
|
83
|
+
if publish_start is not None:
|
|
84
|
+
modifier.append(Filter(query_str="filter[publish_start]=" + str(publish_start)))
|
|
85
|
+
if publish_end is not None:
|
|
86
|
+
modifier.append(Filter(query_str="filter[publish_end]=" + str(publish_end)))
|
|
87
|
+
if created_at is not None:
|
|
88
|
+
modifier.append(Filter(query_str="filter[created_at]=" + str(created_at)))
|
|
89
|
+
if updated_at is not None:
|
|
90
|
+
modifier.append(Filter(query_str="filter[updated_at]=" + str(updated_at)))
|
|
91
|
+
if parent is not None:
|
|
92
|
+
modifier.append(Filter(parent=str(parent)))
|
|
93
|
+
|
|
94
|
+
# Table definition
|
|
95
|
+
tabledef = [
|
|
96
|
+
{"header": Column("Id", no_wrap=True), "column": "id"},
|
|
97
|
+
{"header": "Name", "column": "name"},
|
|
98
|
+
{"header": "Product type", "column": "product_type"},
|
|
99
|
+
{"header": "Price", "column": "price"},
|
|
100
|
+
{"header": "Publish start", "column": "publish_start"},
|
|
101
|
+
{"header": "Created", "column": "created_at"},
|
|
102
|
+
{"header": "Updated", "column": "updated_at"},
|
|
103
|
+
]
|
|
104
|
+
async with Connection() as conn:
|
|
105
|
+
await list_resources(ctx, Product(conn), tabledef, modifier)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@app.async_command()
|
|
109
|
+
async def show(
|
|
110
|
+
ctx: typer.Context,
|
|
111
|
+
product_id: Annotated[UUID, typer.Argument()],
|
|
112
|
+
):
|
|
113
|
+
# Show resource
|
|
114
|
+
try:
|
|
115
|
+
async with Connection() as conn:
|
|
116
|
+
ctrl = Product(conn)
|
|
117
|
+
model = await ctrl.fetch(product_id)
|
|
118
|
+
|
|
119
|
+
show_resource(ctx, model)
|
|
120
|
+
except DocumentError as e:
|
|
121
|
+
await print_document_error(e)
|
|
@@ -0,0 +1,127 @@
|
|
|
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 Purchase, PurchaseModel
|
|
17
|
+
|
|
18
|
+
# Create typer object
|
|
19
|
+
app = AsyncTyper()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.async_command()
|
|
23
|
+
async def list(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
product_type: Annotated[
|
|
26
|
+
Optional[str], typer.Option(help="Automatically set based on chosen product.")
|
|
27
|
+
] = None,
|
|
28
|
+
description: Annotated[
|
|
29
|
+
Optional[str], typer.Option(help="Readonly on update.")
|
|
30
|
+
] = None,
|
|
31
|
+
units: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
32
|
+
date_purchase: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
33
|
+
date_activation: Annotated[
|
|
34
|
+
Optional[str],
|
|
35
|
+
typer.Option(
|
|
36
|
+
help="Will be stored as UTC time. Multiple formats are allowed such as: Y-m-d | Y-m-d H:i:s"
|
|
37
|
+
),
|
|
38
|
+
] = None,
|
|
39
|
+
date_deactivation: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
40
|
+
date_next_bill: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
41
|
+
bill_sequence: Annotated[
|
|
42
|
+
Optional[str],
|
|
43
|
+
typer.Option(
|
|
44
|
+
help="This will indicate the billing sequence. E.g. 1M = monthly, 1Y = yearly."
|
|
45
|
+
),
|
|
46
|
+
] = None,
|
|
47
|
+
created_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
48
|
+
updated_at: Annotated[Optional[str], typer.Option(help="")] = None,
|
|
49
|
+
account: Annotated[
|
|
50
|
+
Optional[UUID], typer.Option(help="Existing account. Readonly on update.")
|
|
51
|
+
] = None,
|
|
52
|
+
parent: Annotated[
|
|
53
|
+
Optional[UUID],
|
|
54
|
+
typer.Option(
|
|
55
|
+
help="If purchase has parent, existing purchase. Readonly on update."
|
|
56
|
+
),
|
|
57
|
+
] = None,
|
|
58
|
+
product: Annotated[
|
|
59
|
+
Optional[UUID], typer.Option(help="Existing product. Readonly on update.")
|
|
60
|
+
] = None,
|
|
61
|
+
):
|
|
62
|
+
# Build modifier
|
|
63
|
+
modifier = []
|
|
64
|
+
if product_type is not None:
|
|
65
|
+
modifier.append(Filter(query_str="filter[product_type]=" + str(product_type)))
|
|
66
|
+
if description is not None:
|
|
67
|
+
modifier.append(Filter(description=description))
|
|
68
|
+
if units is not None:
|
|
69
|
+
modifier.append(Filter(units=units))
|
|
70
|
+
if date_purchase is not None:
|
|
71
|
+
modifier.append(Filter(query_str="filter[date_purchase]=" + str(date_purchase)))
|
|
72
|
+
if date_activation is not None:
|
|
73
|
+
modifier.append(
|
|
74
|
+
Filter(query_str="filter[date_activation]=" + str(date_activation))
|
|
75
|
+
)
|
|
76
|
+
if date_deactivation is not None:
|
|
77
|
+
modifier.append(
|
|
78
|
+
Filter(query_str="filter[date_deactivation]=" + str(date_deactivation))
|
|
79
|
+
)
|
|
80
|
+
if date_next_bill is not None:
|
|
81
|
+
modifier.append(
|
|
82
|
+
Filter(query_str="filter[date_next_bill]=" + str(date_next_bill))
|
|
83
|
+
)
|
|
84
|
+
if bill_sequence is not None:
|
|
85
|
+
modifier.append(Filter(query_str="filter[bill_sequence]=" + str(bill_sequence)))
|
|
86
|
+
if created_at is not None:
|
|
87
|
+
modifier.append(Filter(query_str="filter[created_at]=" + str(created_at)))
|
|
88
|
+
if updated_at is not None:
|
|
89
|
+
modifier.append(Filter(query_str="filter[updated_at]=" + str(updated_at)))
|
|
90
|
+
if account is not None:
|
|
91
|
+
modifier.append(Filter(account=str(account)))
|
|
92
|
+
if parent is not None:
|
|
93
|
+
modifier.append(Filter(parent=str(parent)))
|
|
94
|
+
if product is not None:
|
|
95
|
+
modifier.append(Filter(product=str(product)))
|
|
96
|
+
modifier.append(Inclusion("account"))
|
|
97
|
+
modifier.append(Inclusion("product"))
|
|
98
|
+
|
|
99
|
+
# Table definition
|
|
100
|
+
tabledef = [
|
|
101
|
+
{"header": Column("Id", no_wrap=True), "column": "id"},
|
|
102
|
+
{"header": "Account", "column": "account", "nested_column": "name"},
|
|
103
|
+
{"header": "Product", "column": "product", "nested_column": "name"},
|
|
104
|
+
{"header": "Description", "column": "description"},
|
|
105
|
+
{"header": "Units", "column": "units"},
|
|
106
|
+
{"header": "Date activation", "column": "date_activation"},
|
|
107
|
+
{"header": "Created", "column": "created_at"},
|
|
108
|
+
{"header": "Updated", "column": "updated_at"},
|
|
109
|
+
]
|
|
110
|
+
async with Connection() as conn:
|
|
111
|
+
await list_resources(ctx, Purchase(conn), tabledef, modifier)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@app.async_command()
|
|
115
|
+
async def show(
|
|
116
|
+
ctx: typer.Context,
|
|
117
|
+
purchase_id: Annotated[UUID, typer.Argument()],
|
|
118
|
+
):
|
|
119
|
+
# Show resource
|
|
120
|
+
try:
|
|
121
|
+
async with Connection() as conn:
|
|
122
|
+
ctrl = Purchase(conn)
|
|
123
|
+
model = await ctrl.fetch(purchase_id)
|
|
124
|
+
|
|
125
|
+
show_resource(ctx, model)
|
|
126
|
+
except DocumentError as e:
|
|
127
|
+
await print_document_error(e)
|
cacholong_cli/common.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Common functionality
|
|
2
|
+
from typing import List
|
|
3
|
+
from enum import Enum
|
|
4
|
+
import typer
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.table import Table
|
|
7
|
+
from cacholong_cli.connection import Connection
|
|
8
|
+
import json
|
|
9
|
+
from cacholong_sdk import BaseController, BaseModel
|
|
10
|
+
from cacholong_sdk import Modifier, Sort, SparseField, DocumentError
|
|
11
|
+
from uuid import UUID
|
|
12
|
+
|
|
13
|
+
ErrorConsole = Console(stderr=True, style="bold red")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class UUIDEncoder(json.JSONEncoder):
|
|
17
|
+
def default(self, obj):
|
|
18
|
+
if isinstance(obj, UUID):
|
|
19
|
+
return str(obj)
|
|
20
|
+
return json.JSONEncoder.default(self, obj)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OutputFormat(str, Enum):
|
|
24
|
+
TABLE = "table"
|
|
25
|
+
JSON = "json"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async def print_document_error(doc_error: DocumentError):
|
|
29
|
+
ErrorConsole.print("Status: {}".format(doc_error.errors["status_code"]))
|
|
30
|
+
js = await doc_error.response.json()
|
|
31
|
+
i = 1
|
|
32
|
+
for error in js["errors"]:
|
|
33
|
+
detail = ""
|
|
34
|
+
if "detail" in error:
|
|
35
|
+
detail = error["detail"]
|
|
36
|
+
ErrorConsole.print("{}: {}: {}".format(i, error["title"], detail))
|
|
37
|
+
i = i + 1
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
async def _perform_list_resources(
|
|
41
|
+
controller: BaseController, modifier: Modifier, tabledef, callback
|
|
42
|
+
):
|
|
43
|
+
relations = [
|
|
44
|
+
relation["column"] for relation in tabledef if "nested_column" in relation
|
|
45
|
+
]
|
|
46
|
+
async for resource in controller.fetch_all(modifier):
|
|
47
|
+
for relation in relations:
|
|
48
|
+
await resource[relation].fetch()
|
|
49
|
+
callback(resource)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def _perform_list_relation_resources(model: BaseModel, relation: str, callback):
|
|
53
|
+
await model[relation].fetch()
|
|
54
|
+
for resource in model[relation].resources:
|
|
55
|
+
callback(resource)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _handle_column(row, column_definition):
|
|
59
|
+
if "nested_column" in column_definition:
|
|
60
|
+
if row[column_definition["column"]].resource != None:
|
|
61
|
+
return str(
|
|
62
|
+
row[column_definition["column"]].resource[
|
|
63
|
+
column_definition["nested_column"]
|
|
64
|
+
]
|
|
65
|
+
)
|
|
66
|
+
return ""
|
|
67
|
+
else:
|
|
68
|
+
return str(row[column_definition["column"]])
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _build_row(row, table, tabledef):
|
|
72
|
+
if any(d["column"] == "id" for d in tabledef):
|
|
73
|
+
table.add_row(
|
|
74
|
+
row.id, *[_handle_column(row, d) for d in tabledef if d["column"] != "id"]
|
|
75
|
+
)
|
|
76
|
+
else:
|
|
77
|
+
table.add_row(
|
|
78
|
+
*[_handle_column(row, d) for d in tabledef if d["column"] != "id"]
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
async def list_resources(
|
|
83
|
+
ctx: typer.Context,
|
|
84
|
+
controller: BaseController,
|
|
85
|
+
tabledef,
|
|
86
|
+
modifier: List[Modifier] = [],
|
|
87
|
+
):
|
|
88
|
+
# Handle sort globally
|
|
89
|
+
if ctx.obj["sort"] is not None and ctx.obj["sort"] != "":
|
|
90
|
+
modifier.append(Sort(ctx.obj["sort"]))
|
|
91
|
+
|
|
92
|
+
# Only fetch the data needed
|
|
93
|
+
if ctx.obj["output"] == OutputFormat.TABLE:
|
|
94
|
+
modifier.append(
|
|
95
|
+
SparseField(
|
|
96
|
+
controller.resource,
|
|
97
|
+
*list(
|
|
98
|
+
dict.fromkeys(
|
|
99
|
+
[d["column"] for d in tabledef if d["column"] != "id"]
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Build modifier (query parameters)
|
|
106
|
+
mod = modifier[0]
|
|
107
|
+
for m in modifier[1:]:
|
|
108
|
+
mod = mod + m
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
if ctx.obj["output"] == OutputFormat.TABLE:
|
|
112
|
+
console = Console()
|
|
113
|
+
table = Table(*[d["header"] for d in tabledef])
|
|
114
|
+
await _perform_list_resources(
|
|
115
|
+
controller, mod, tabledef, lambda row: _build_row(row, table, tabledef)
|
|
116
|
+
)
|
|
117
|
+
console.print(table)
|
|
118
|
+
elif ctx.obj["output"] == OutputFormat.JSON:
|
|
119
|
+
data = []
|
|
120
|
+
await _perform_list_resources(
|
|
121
|
+
controller, mod, tabledef, lambda row: data.append(row.json)
|
|
122
|
+
)
|
|
123
|
+
print(json.dumps(data))
|
|
124
|
+
except DocumentError as e:
|
|
125
|
+
await print_document_error(e)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
async def list_relation_resources(
|
|
129
|
+
ctx: typer.Context,
|
|
130
|
+
model: BaseModel,
|
|
131
|
+
relation: str,
|
|
132
|
+
tabledef,
|
|
133
|
+
modifier: List[Modifier] = [],
|
|
134
|
+
):
|
|
135
|
+
# Handle sort globally
|
|
136
|
+
# if ctx.obj["sort"] is not None and ctx.obj["sort"] != "":
|
|
137
|
+
# modifier.append(Sort(ctx.obj["sort"]))
|
|
138
|
+
#
|
|
139
|
+
# # Only fetch the data needed
|
|
140
|
+
# if ctx.obj["output"] == OutputFormat.TABLE:
|
|
141
|
+
# modifier.append(
|
|
142
|
+
# SparseField(
|
|
143
|
+
# controller.resource,
|
|
144
|
+
# *[d["column"] for d in tabledef if d["column"] != "id"]
|
|
145
|
+
# )
|
|
146
|
+
# )
|
|
147
|
+
#
|
|
148
|
+
# # Build modifier (query parameters)
|
|
149
|
+
# mod = modifier[0]
|
|
150
|
+
# for m in modifier[1:]:
|
|
151
|
+
# mod = mod + m
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
if ctx.obj["output"] == OutputFormat.TABLE:
|
|
155
|
+
console = Console()
|
|
156
|
+
table = Table(*[d["header"] for d in tabledef])
|
|
157
|
+
await _perform_list_relation_resources(
|
|
158
|
+
model, relation, lambda row: _build_row(row, table, tabledef)
|
|
159
|
+
)
|
|
160
|
+
console.print(table)
|
|
161
|
+
elif ctx.obj["output"] == OutputFormat.JSON:
|
|
162
|
+
data = []
|
|
163
|
+
await _perform_list_relation_resources(
|
|
164
|
+
model, relation, lambda row: data.append(row.json)
|
|
165
|
+
)
|
|
166
|
+
print(json.dumps(data))
|
|
167
|
+
except DocumentError as e:
|
|
168
|
+
await print_document_error(e)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def show_resource(
|
|
172
|
+
ctx: typer.Context,
|
|
173
|
+
model: BaseModel,
|
|
174
|
+
):
|
|
175
|
+
if ctx.obj["output"] == OutputFormat.TABLE:
|
|
176
|
+
console = Console()
|
|
177
|
+
console.print(model)
|
|
178
|
+
elif ctx.obj["output"] == OutputFormat.JSON:
|
|
179
|
+
print(json.dumps(model.json, cls=UUIDEncoder))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from cacholong_sdk.connection import connection as Conn
|
|
2
|
+
import os
|
|
3
|
+
import configparser
|
|
4
|
+
from xdg import BaseDirectory
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Connection(Conn):
|
|
8
|
+
def __init__(self, headers={}):
|
|
9
|
+
# Read the user.ini file
|
|
10
|
+
configpath = BaseDirectory.save_config_path("cacholong-cli")
|
|
11
|
+
self.cfg = configparser.ConfigParser()
|
|
12
|
+
self.cfg.read(os.path.join(configpath, "config.ini"))
|
|
13
|
+
|
|
14
|
+
api_url = self.cfg["DEFAULT"]["api_url"].strip("'")
|
|
15
|
+
api_key = self.cfg["DEFAULT"]["api_key"].strip("'")
|
|
16
|
+
|
|
17
|
+
# Call parent constructor
|
|
18
|
+
super().__init__(api_url, api_key, headers)
|
|
@@ -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,39 @@
|
|
|
1
|
+
cacholong_cli/AsyncTyper.py,sha256=uR1lGZyyDEuflNvxKuAmVUP-DTE55PzZL5c0c3l2h4U,425
|
|
2
|
+
cacholong_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
cacholong_cli/cli.py,sha256=5Rjjh8c3hTyvbM8WPyqNwvyu4Dm-ThhK3KhBj5Eazkk,3320
|
|
4
|
+
cacholong_cli/commands/accounts.py,sha256=4adSslyQ4gU3xK3P1Jfnbu89CrUHK4s0IfRNO8w_0Qs,3769
|
|
5
|
+
cacholong_cli/commands/addresses.py,sha256=BxnAPRICinDfQbagjkV2EGDEEFt1RLgge4hdDAFUPxc,9263
|
|
6
|
+
cacholong_cli/commands/companies.py,sha256=lB95iNO4eP47fGLMUqJ0k5nIy58IE8DCOZdkHltQHOE,3347
|
|
7
|
+
cacholong_cli/commands/dns_records.py,sha256=zO6oxPv3ZzTxRSBDKzTpXxZbMbmA4Znm9xCsp07tJsU,11087
|
|
8
|
+
cacholong_cli/commands/dns_templates.py,sha256=fq9YRz4ZVW_Vy8EDb3hncclFPKQbr_BJkyHQo5mKuqw,4472
|
|
9
|
+
cacholong_cli/commands/dns_zones.py,sha256=Hk1ProLhOWTey51JquE-xGpLa1YfUlfsEZza3Q8uhz8,9339
|
|
10
|
+
cacholong_cli/commands/products.py,sha256=sskNAVLpIwcmeYaMJR6Y31jgL8IAiVeyyQMuOMqgtDs,4186
|
|
11
|
+
cacholong_cli/commands/purchases.py,sha256=U1vLXtMMVucUX34EDYmFlBoqRhjuHCblM_i8qkixR-E,4721
|
|
12
|
+
cacholong_cli/common.py,sha256=wpCOQgyyEqGna23nLFbNQqHkrC_TSY_e6cyCSf2UZxY,5439
|
|
13
|
+
cacholong_cli/connection.py,sha256=lRGQbQohLdYh8ktaREGcTrUUxInBNC00jY-Dj-Fcs40,597
|
|
14
|
+
cacholong_sdk/__init__.py,sha256=gGzTvOozQSi-F1hx_PhQVLmH47b7CzXPCi2jKbwQSFM,727
|
|
15
|
+
cacholong_sdk/account.py,sha256=PvmuKycAgIs8-vhNaRFVE8dC2k4GX4xc6QQ6P9_CMjA,272
|
|
16
|
+
cacholong_sdk/address.py,sha256=TEcys-uwQ9pOUQ05Xvm7NEicgXkX9hBVop2Q3gfodYw,273
|
|
17
|
+
cacholong_sdk/api_schema.py,sha256=E0dci_MEbExJ58UTxx3la7wBiYn42R2ufvmzcuZZuF4,5670
|
|
18
|
+
cacholong_sdk/common.py,sha256=LMVa_4S7XpO1oZPEmDhf-Qev9d0TNFDiNV5iXteyan8,3603
|
|
19
|
+
cacholong_sdk/company.py,sha256=X4oB8wlDyOHi4PuqAnVJyo_JGJKm7chCHp70Sa2w7zw,273
|
|
20
|
+
cacholong_sdk/connection.py,sha256=xgoSZAFD1_o-b6GAbwKeFlJgpTLJce2XI1yGxlGjBik,657
|
|
21
|
+
cacholong_sdk/dns_record.py,sha256=lJI_8dUsSnKjeZNHHzBQdohMv8o6ocz6utN0t634SQc,283
|
|
22
|
+
cacholong_sdk/dns_template.py,sha256=xo55JX2eyRUqyQontKZfYCZEwNKIuPJx5n0yFq2gtC8,293
|
|
23
|
+
cacholong_sdk/dns_zone.py,sha256=kCarok1OHqOEKvk-AC-mM7HrElpnviR6EzmdjXvc-yk,273
|
|
24
|
+
cacholong_sdk/exception.py,sha256=vJ3ggdFpV8UyuxXI_XF4vZ4VADnqVazXW2-CcIKr-LI,213
|
|
25
|
+
cacholong_sdk/product.py,sha256=s_WPhbXpX7Z8JVFK3pqzBd5RcOkApVi0t-7wComxNn0,272
|
|
26
|
+
cacholong_sdk/purchase.py,sha256=cJ5-yTl-dampDzPUgacdZzg8i-nFyosLbUjJ0MK5n6U,277
|
|
27
|
+
jsonapi_client/__init__.py,sha256=WMaKBvXcR2y_bF6VAWC5ZHMFZi4yVhl6E4BJpZNTlKI,1869
|
|
28
|
+
jsonapi_client/common.py,sha256=quY5rGICo7akZx4BCpbK9ReSVs1PWsknaeRW-fFMTIw,5265
|
|
29
|
+
jsonapi_client/document.py,sha256=InTdbBtpQhjBpOpOial2OTuVaEIR-p0AU9QrMYRTq8Y,5988
|
|
30
|
+
jsonapi_client/exceptions.py,sha256=nydaeDdnkrXUtu2ZJIF9dyN2xsZbuxaLQ-v3opMz7sY,2221
|
|
31
|
+
jsonapi_client/filter.py,sha256=6eROQ4j_d3BrZzinZU9x-eBKRcXCPvCA9oosifmU-Tw,5541
|
|
32
|
+
jsonapi_client/objects.py,sha256=2WcdrfDvnbpu4VYvfpzDFaJuqtIcfrizVEQZOQuN8p0,5918
|
|
33
|
+
jsonapi_client/relationships.py,sha256=UmbJ6Dj2prNZ5_W8URaFPabZETlwYZloIoJ43MKJ-Hk,15891
|
|
34
|
+
jsonapi_client/resourceobject.py,sha256=YYv7Qp1bqE3QGkhgWGbxXWpPBxUjwwxRbzK1LHb-ckg,24280
|
|
35
|
+
jsonapi_client/session.py,sha256=T-3yhyeyi3CwHGk-_KVnTH9zIZNUzPNC43r110YDqXg,28290
|
|
36
|
+
cacholong_cloud_cli-0.3.0.dist-info/METADATA,sha256=jP4ZXhn7n6zeyUj8zW3tHMfhx3INDpM-slkhrBxPDu8,7010
|
|
37
|
+
cacholong_cloud_cli-0.3.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
38
|
+
cacholong_cloud_cli-0.3.0.dist-info/entry_points.txt,sha256=YEsua905n79qKpapwJPPD2pPpO6PB_OuveO8MZUgZ_g,48
|
|
39
|
+
cacholong_cloud_cli-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Import connection / base controller and model
|
|
2
|
+
from .connection import connection
|
|
3
|
+
from .common import BaseController, BaseModel
|
|
4
|
+
|
|
5
|
+
# Import models / controllers
|
|
6
|
+
from .account import AccountModel, Account
|
|
7
|
+
from .address import AddressModel, Address
|
|
8
|
+
from .company import CompanyModel, Company
|
|
9
|
+
from .dns_record import DnsRecordModel, DnsRecord
|
|
10
|
+
from .dns_template import DnsTemplateModel, DnsTemplate
|
|
11
|
+
from .dns_zone import DnsZoneModel, DnsZone
|
|
12
|
+
from .product import ProductModel, Product
|
|
13
|
+
from .purchase import PurchaseModel, Purchase
|
|
14
|
+
|
|
15
|
+
# Import directly from jsonapi
|
|
16
|
+
from jsonapi_client import Modifier, Filter, Inclusion, Sort, SparseField
|
|
17
|
+
from jsonapi_client import ResourceTuple
|
|
18
|
+
from jsonapi_client.exceptions import DocumentError
|
cacholong_sdk/account.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .common import BaseController, BaseModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AccountModel(BaseModel):
|
|
5
|
+
pass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Account(BaseController[AccountModel]):
|
|
9
|
+
_class = AccountModel
|
|
10
|
+
|
|
11
|
+
def __init__(self, connection):
|
|
12
|
+
self._resource = "accounts"
|
|
13
|
+
|
|
14
|
+
super().__init__(connection)
|
cacholong_sdk/address.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .common import BaseController, BaseModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AddressModel(BaseModel):
|
|
5
|
+
pass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Address(BaseController[AddressModel]):
|
|
9
|
+
_class = AddressModel
|
|
10
|
+
|
|
11
|
+
def __init__(self, connection):
|
|
12
|
+
self._resource = "addresses"
|
|
13
|
+
|
|
14
|
+
super().__init__(connection)
|