hostinger-api 1.0.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.
Files changed (88) hide show
  1. hostinger_api/__init__.py +105 -0
  2. hostinger_api/api/__init__.py +21 -0
  3. hostinger_api/api/billing_catalog_api.py +282 -0
  4. hostinger_api/api/billing_orders_api.py +313 -0
  5. hostinger_api/api/billing_payment_methods_api.py +819 -0
  6. hostinger_api/api/billing_subscriptions_api.py +584 -0
  7. hostinger_api/api/domains_portfolio_api.py +282 -0
  8. hostinger_api/api/vps_actions_api.py +599 -0
  9. hostinger_api/api/vps_backups_api.py +882 -0
  10. hostinger_api/api/vps_data_centers_api.py +282 -0
  11. hostinger_api/api/vps_firewall_api.py +2872 -0
  12. hostinger_api/api/vps_malware_scanner_api.py +842 -0
  13. hostinger_api/api/vps_post_install_scripts_api.py +1419 -0
  14. hostinger_api/api/vps_public_keys_api.py +1154 -0
  15. hostinger_api/api/vps_recovery_api.py +597 -0
  16. hostinger_api/api/vps_snapshots_api.py +1100 -0
  17. hostinger_api/api/vps_virtual_machine_api.py +3714 -0
  18. hostinger_api/api/vpsos_templates_api.py +551 -0
  19. hostinger_api/api/vpsptr_records_api.py +565 -0
  20. hostinger_api/api_client.py +795 -0
  21. hostinger_api/api_response.py +21 -0
  22. hostinger_api/configuration.py +579 -0
  23. hostinger_api/exceptions.py +214 -0
  24. hostinger_api/models/__init__.py +72 -0
  25. hostinger_api/models/billing_v1_catalog_catalog_item_price_resource.py +107 -0
  26. hostinger_api/models/billing_v1_catalog_catalog_item_resource.py +99 -0
  27. hostinger_api/models/billing_v1_order_order_billing_address_resource.py +145 -0
  28. hostinger_api/models/billing_v1_order_order_resource.py +116 -0
  29. hostinger_api/models/billing_v1_order_store_request.py +97 -0
  30. hostinger_api/models/billing_v1_order_store_request_items_inner.py +87 -0
  31. hostinger_api/models/billing_v1_payment_method_payment_method_resource.py +102 -0
  32. hostinger_api/models/billing_v1_subscription_cancel_request.py +117 -0
  33. hostinger_api/models/billing_v1_subscription_subscription_resource.py +130 -0
  34. hostinger_api/models/common_schema_error_response_schema.py +87 -0
  35. hostinger_api/models/common_schema_pagination_meta_schema.py +89 -0
  36. hostinger_api/models/common_schema_unauthorized_response_schema.py +87 -0
  37. hostinger_api/models/common_schema_unprocessable_content_response_schema.py +93 -0
  38. hostinger_api/models/common_schema_unprocessable_content_response_schema_errors.py +87 -0
  39. hostinger_api/models/common_success_empty_resource.py +85 -0
  40. hostinger_api/models/domains_v1_domain_domain_resource.py +126 -0
  41. hostinger_api/models/vps_get_action_list_v1200_response.py +99 -0
  42. hostinger_api/models/vps_get_backup_list_v1200_response.py +99 -0
  43. hostinger_api/models/vps_get_firewall_list_v1200_response.py +99 -0
  44. hostinger_api/models/vps_get_post_install_script_list_v1200_response.py +99 -0
  45. hostinger_api/models/vps_get_public_key_list_v1200_response.py +99 -0
  46. hostinger_api/models/vpsv1_action_action_resource.py +104 -0
  47. hostinger_api/models/vpsv1_backup_backup_resource.py +90 -0
  48. hostinger_api/models/vpsv1_data_center_data_center_resource.py +113 -0
  49. hostinger_api/models/vpsv1_firewall_firewall_resource.py +104 -0
  50. hostinger_api/models/vpsv1_firewall_firewall_rule_resource.py +115 -0
  51. hostinger_api/models/vpsv1_firewall_rules_store_request.py +105 -0
  52. hostinger_api/models/vpsv1_firewall_store_request.py +85 -0
  53. hostinger_api/models/vpsv1_ip_address_ip_address_resource.py +94 -0
  54. hostinger_api/models/vpsv1_malware_metrics_resource.py +101 -0
  55. hostinger_api/models/vpsv1_metrics_metrics_collection.py +149 -0
  56. hostinger_api/models/vpsv1_metrics_metrics_collection_cpu_usage.py +127 -0
  57. hostinger_api/models/vpsv1_metrics_metrics_collection_disk_space.py +127 -0
  58. hostinger_api/models/vpsv1_metrics_metrics_collection_incoming_traffic.py +127 -0
  59. hostinger_api/models/vpsv1_metrics_metrics_collection_outgoing_traffic.py +127 -0
  60. hostinger_api/models/vpsv1_metrics_metrics_collection_ram_usage.py +127 -0
  61. hostinger_api/models/vpsv1_metrics_metrics_collection_uptime.py +127 -0
  62. hostinger_api/models/vpsv1_metrics_metrics_resource.py +87 -0
  63. hostinger_api/models/vpsv1_post_install_script_post_install_script_resource.py +94 -0
  64. hostinger_api/models/vpsv1_post_install_script_store_request.py +87 -0
  65. hostinger_api/models/vpsv1_public_key_attach_request.py +85 -0
  66. hostinger_api/models/vpsv1_public_key_public_key_resource.py +89 -0
  67. hostinger_api/models/vpsv1_public_key_store_request.py +87 -0
  68. hostinger_api/models/vpsv1_snapshot_snapshot_resource.py +90 -0
  69. hostinger_api/models/vpsv1_template_template_resource.py +96 -0
  70. hostinger_api/models/vpsv1_virtual_machine_hostname_update_request.py +85 -0
  71. hostinger_api/models/vpsv1_virtual_machine_metric_get_request.py +88 -0
  72. hostinger_api/models/vpsv1_virtual_machine_nameservers_update_request.py +87 -0
  73. hostinger_api/models/vpsv1_virtual_machine_panel_password_update_request.py +86 -0
  74. hostinger_api/models/vpsv1_virtual_machine_recovery_start_request.py +85 -0
  75. hostinger_api/models/vpsv1_virtual_machine_recreate_request.py +90 -0
  76. hostinger_api/models/vpsv1_virtual_machine_root_password_update_request.py +86 -0
  77. hostinger_api/models/vpsv1_virtual_machine_setup_request.py +108 -0
  78. hostinger_api/models/vpsv1_virtual_machine_setup_request_public_key.py +87 -0
  79. hostinger_api/models/vpsv1_virtual_machine_virtual_machine_resource.py +190 -0
  80. hostinger_api/models/vpsv1_virtual_machine_virtual_machine_resource_ipv4.py +131 -0
  81. hostinger_api/models/vpsv1_virtual_machine_virtual_machine_resource_ipv6.py +131 -0
  82. hostinger_api/models/vpsv1_virtual_machine_virtual_machine_resource_template.py +127 -0
  83. hostinger_api/py.typed +0 -0
  84. hostinger_api/rest.py +256 -0
  85. hostinger_api-1.0.0.dist-info/METADATA +26 -0
  86. hostinger_api-1.0.0.dist-info/RECORD +88 -0
  87. hostinger_api-1.0.0.dist-info/WHEEL +5 -0
  88. hostinger_api-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,214 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger API Python SDK
5
+
6
+ API Version: 0.0.1-beta
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+ from typing import Any, Optional
13
+ from typing_extensions import Self
14
+
15
+ class OpenApiException(Exception):
16
+ """The base exception class for all OpenAPIExceptions"""
17
+
18
+
19
+ class ApiTypeError(OpenApiException, TypeError):
20
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
21
+ key_type=None) -> None:
22
+ """ Raises an exception for TypeErrors
23
+
24
+ Args:
25
+ msg (str): the exception message
26
+
27
+ Keyword Args:
28
+ path_to_item (list): a list of keys an indices to get to the
29
+ current_item
30
+ None if unset
31
+ valid_classes (tuple): the primitive classes that current item
32
+ should be an instance of
33
+ None if unset
34
+ key_type (bool): False if our value is a value in a dict
35
+ True if it is a key in a dict
36
+ False if our item is an item in a list
37
+ None if unset
38
+ """
39
+ self.path_to_item = path_to_item
40
+ self.valid_classes = valid_classes
41
+ self.key_type = key_type
42
+ full_msg = msg
43
+ if path_to_item:
44
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45
+ super(ApiTypeError, self).__init__(full_msg)
46
+
47
+
48
+ class ApiValueError(OpenApiException, ValueError):
49
+ def __init__(self, msg, path_to_item=None) -> None:
50
+ """
51
+ Args:
52
+ msg (str): the exception message
53
+
54
+ Keyword Args:
55
+ path_to_item (list) the path to the exception in the
56
+ received_data dict. None if unset
57
+ """
58
+
59
+ self.path_to_item = path_to_item
60
+ full_msg = msg
61
+ if path_to_item:
62
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63
+ super(ApiValueError, self).__init__(full_msg)
64
+
65
+
66
+ class ApiAttributeError(OpenApiException, AttributeError):
67
+ def __init__(self, msg, path_to_item=None) -> None:
68
+ """
69
+ Raised when an attribute reference or assignment fails.
70
+
71
+ Args:
72
+ msg (str): the exception message
73
+
74
+ Keyword Args:
75
+ path_to_item (None/list) the path to the exception in the
76
+ received_data dict
77
+ """
78
+ self.path_to_item = path_to_item
79
+ full_msg = msg
80
+ if path_to_item:
81
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82
+ super(ApiAttributeError, self).__init__(full_msg)
83
+
84
+
85
+ class ApiKeyError(OpenApiException, KeyError):
86
+ def __init__(self, msg, path_to_item=None) -> None:
87
+ """
88
+ Args:
89
+ msg (str): the exception message
90
+
91
+ Keyword Args:
92
+ path_to_item (None/list) the path to the exception in the
93
+ received_data dict
94
+ """
95
+ self.path_to_item = path_to_item
96
+ full_msg = msg
97
+ if path_to_item:
98
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99
+ super(ApiKeyError, self).__init__(full_msg)
100
+
101
+
102
+ class ApiException(OpenApiException):
103
+
104
+ def __init__(
105
+ self,
106
+ status=None,
107
+ reason=None,
108
+ http_resp=None,
109
+ *,
110
+ body: Optional[str] = None,
111
+ data: Optional[Any] = None,
112
+ ) -> None:
113
+ self.status = status
114
+ self.reason = reason
115
+ self.body = body
116
+ self.data = data
117
+ self.headers = None
118
+
119
+ if http_resp:
120
+ if self.status is None:
121
+ self.status = http_resp.status
122
+ if self.reason is None:
123
+ self.reason = http_resp.reason
124
+ if self.body is None:
125
+ try:
126
+ self.body = http_resp.data.decode('utf-8')
127
+ except Exception:
128
+ pass
129
+ self.headers = http_resp.getheaders()
130
+
131
+ @classmethod
132
+ def from_response(
133
+ cls,
134
+ *,
135
+ http_resp,
136
+ body: Optional[str],
137
+ data: Optional[Any],
138
+ ) -> Self:
139
+ if http_resp.status == 400:
140
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
141
+
142
+ if http_resp.status == 401:
143
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 403:
146
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 404:
149
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
150
+
151
+ # Added new conditions for 409 and 422
152
+ if http_resp.status == 409:
153
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
154
+
155
+ if http_resp.status == 422:
156
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
157
+
158
+ if 500 <= http_resp.status <= 599:
159
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
160
+ raise ApiException(http_resp=http_resp, body=body, data=data)
161
+
162
+ def __str__(self):
163
+ """Custom error messages for exception"""
164
+ error_message = "({0})\n"\
165
+ "Reason: {1}\n".format(self.status, self.reason)
166
+ if self.headers:
167
+ error_message += "HTTP response headers: {0}\n".format(
168
+ self.headers)
169
+
170
+ if self.data or self.body:
171
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
172
+
173
+ return error_message
174
+
175
+
176
+ class BadRequestException(ApiException):
177
+ pass
178
+
179
+
180
+ class NotFoundException(ApiException):
181
+ pass
182
+
183
+
184
+ class UnauthorizedException(ApiException):
185
+ pass
186
+
187
+
188
+ class ForbiddenException(ApiException):
189
+ pass
190
+
191
+
192
+ class ServiceException(ApiException):
193
+ pass
194
+
195
+
196
+ class ConflictException(ApiException):
197
+ """Exception for HTTP 409 Conflict."""
198
+ pass
199
+
200
+
201
+ class UnprocessableEntityException(ApiException):
202
+ """Exception for HTTP 422 Unprocessable Entity."""
203
+ pass
204
+
205
+
206
+ def render_path(path_to_item):
207
+ """Returns a string representation of a path"""
208
+ result = ""
209
+ for pth in path_to_item:
210
+ if isinstance(pth, int):
211
+ result += "[{0}]".format(pth)
212
+ else:
213
+ result += "['{0}']".format(pth)
214
+ return result
@@ -0,0 +1,72 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ Hostinger API Python SDK
6
+
7
+ API Version: 0.0.1-beta
8
+
9
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11
+ """ # noqa: E501
12
+
13
+
14
+ # import models into model package
15
+ from hostinger_api.models.billing_v1_catalog_catalog_item_price_resource import BillingV1CatalogCatalogItemPriceResource
16
+ from hostinger_api.models.billing_v1_catalog_catalog_item_resource import BillingV1CatalogCatalogItemResource
17
+ from hostinger_api.models.billing_v1_order_order_billing_address_resource import BillingV1OrderOrderBillingAddressResource
18
+ from hostinger_api.models.billing_v1_order_order_resource import BillingV1OrderOrderResource
19
+ from hostinger_api.models.billing_v1_order_store_request import BillingV1OrderStoreRequest
20
+ from hostinger_api.models.billing_v1_order_store_request_items_inner import BillingV1OrderStoreRequestItemsInner
21
+ from hostinger_api.models.billing_v1_payment_method_payment_method_resource import BillingV1PaymentMethodPaymentMethodResource
22
+ from hostinger_api.models.billing_v1_subscription_cancel_request import BillingV1SubscriptionCancelRequest
23
+ from hostinger_api.models.billing_v1_subscription_subscription_resource import BillingV1SubscriptionSubscriptionResource
24
+ from hostinger_api.models.common_schema_error_response_schema import CommonSchemaErrorResponseSchema
25
+ from hostinger_api.models.common_schema_pagination_meta_schema import CommonSchemaPaginationMetaSchema
26
+ from hostinger_api.models.common_schema_unauthorized_response_schema import CommonSchemaUnauthorizedResponseSchema
27
+ from hostinger_api.models.common_schema_unprocessable_content_response_schema import CommonSchemaUnprocessableContentResponseSchema
28
+ from hostinger_api.models.common_schema_unprocessable_content_response_schema_errors import CommonSchemaUnprocessableContentResponseSchemaErrors
29
+ from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
30
+ from hostinger_api.models.domains_v1_domain_domain_resource import DomainsV1DomainDomainResource
31
+ from hostinger_api.models.vps_get_action_list_v1200_response import VPSGetActionListV1200Response
32
+ from hostinger_api.models.vps_get_backup_list_v1200_response import VPSGetBackupListV1200Response
33
+ from hostinger_api.models.vps_get_firewall_list_v1200_response import VPSGetFirewallListV1200Response
34
+ from hostinger_api.models.vps_get_post_install_script_list_v1200_response import VPSGetPostInstallScriptListV1200Response
35
+ from hostinger_api.models.vps_get_public_key_list_v1200_response import VPSGetPublicKeyListV1200Response
36
+ from hostinger_api.models.vpsv1_action_action_resource import VPSV1ActionActionResource
37
+ from hostinger_api.models.vpsv1_backup_backup_resource import VPSV1BackupBackupResource
38
+ from hostinger_api.models.vpsv1_data_center_data_center_resource import VPSV1DataCenterDataCenterResource
39
+ from hostinger_api.models.vpsv1_firewall_firewall_resource import VPSV1FirewallFirewallResource
40
+ from hostinger_api.models.vpsv1_firewall_firewall_rule_resource import VPSV1FirewallFirewallRuleResource
41
+ from hostinger_api.models.vpsv1_firewall_rules_store_request import VPSV1FirewallRulesStoreRequest
42
+ from hostinger_api.models.vpsv1_firewall_store_request import VPSV1FirewallStoreRequest
43
+ from hostinger_api.models.vpsv1_ip_address_ip_address_resource import VPSV1IPAddressIPAddressResource
44
+ from hostinger_api.models.vpsv1_malware_metrics_resource import VPSV1MalwareMetricsResource
45
+ from hostinger_api.models.vpsv1_metrics_metrics_collection import VPSV1MetricsMetricsCollection
46
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_cpu_usage import VPSV1MetricsMetricsCollectionCpuUsage
47
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_disk_space import VPSV1MetricsMetricsCollectionDiskSpace
48
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_incoming_traffic import VPSV1MetricsMetricsCollectionIncomingTraffic
49
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_outgoing_traffic import VPSV1MetricsMetricsCollectionOutgoingTraffic
50
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_ram_usage import VPSV1MetricsMetricsCollectionRamUsage
51
+ from hostinger_api.models.vpsv1_metrics_metrics_collection_uptime import VPSV1MetricsMetricsCollectionUptime
52
+ from hostinger_api.models.vpsv1_metrics_metrics_resource import VPSV1MetricsMetricsResource
53
+ from hostinger_api.models.vpsv1_post_install_script_post_install_script_resource import VPSV1PostInstallScriptPostInstallScriptResource
54
+ from hostinger_api.models.vpsv1_post_install_script_store_request import VPSV1PostInstallScriptStoreRequest
55
+ from hostinger_api.models.vpsv1_public_key_attach_request import VPSV1PublicKeyAttachRequest
56
+ from hostinger_api.models.vpsv1_public_key_public_key_resource import VPSV1PublicKeyPublicKeyResource
57
+ from hostinger_api.models.vpsv1_public_key_store_request import VPSV1PublicKeyStoreRequest
58
+ from hostinger_api.models.vpsv1_snapshot_snapshot_resource import VPSV1SnapshotSnapshotResource
59
+ from hostinger_api.models.vpsv1_template_template_resource import VPSV1TemplateTemplateResource
60
+ from hostinger_api.models.vpsv1_virtual_machine_hostname_update_request import VPSV1VirtualMachineHostnameUpdateRequest
61
+ from hostinger_api.models.vpsv1_virtual_machine_metric_get_request import VPSV1VirtualMachineMetricGetRequest
62
+ from hostinger_api.models.vpsv1_virtual_machine_nameservers_update_request import VPSV1VirtualMachineNameserversUpdateRequest
63
+ from hostinger_api.models.vpsv1_virtual_machine_panel_password_update_request import VPSV1VirtualMachinePanelPasswordUpdateRequest
64
+ from hostinger_api.models.vpsv1_virtual_machine_recovery_start_request import VPSV1VirtualMachineRecoveryStartRequest
65
+ from hostinger_api.models.vpsv1_virtual_machine_recreate_request import VPSV1VirtualMachineRecreateRequest
66
+ from hostinger_api.models.vpsv1_virtual_machine_root_password_update_request import VPSV1VirtualMachineRootPasswordUpdateRequest
67
+ from hostinger_api.models.vpsv1_virtual_machine_setup_request import VPSV1VirtualMachineSetupRequest
68
+ from hostinger_api.models.vpsv1_virtual_machine_setup_request_public_key import VPSV1VirtualMachineSetupRequestPublicKey
69
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource import VPSV1VirtualMachineVirtualMachineResource
70
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_ipv4 import VPSV1VirtualMachineVirtualMachineResourceIpv4
71
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_ipv6 import VPSV1VirtualMachineVirtualMachineResourceIpv6
72
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_template import VPSV1VirtualMachineVirtualMachineResourceTemplate
@@ -0,0 +1,107 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger API Python SDK
5
+
6
+ API Version: 0.0.1-beta
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
19
+ from typing import Any, ClassVar, Dict, List, Optional
20
+ from typing import Optional, Set
21
+ from typing_extensions import Self
22
+
23
+ class BillingV1CatalogCatalogItemPriceResource(BaseModel):
24
+ """
25
+ BillingV1CatalogCatalogItemPriceResource
26
+ """ # noqa: E501
27
+ id: Optional[StrictStr] = Field(default=None, description="Price item ID")
28
+ name: Optional[StrictStr] = Field(default=None, description="Price item name")
29
+ currency: Optional[StrictStr] = Field(default=None, description="Currency code")
30
+ price: Optional[StrictInt] = Field(default=None, description="Price in cents")
31
+ first_period_price: Optional[StrictInt] = Field(default=None, description="First period price in cents")
32
+ period: Optional[StrictInt] = Field(default=None, description="Period")
33
+ period_unit: Optional[StrictStr] = Field(default=None, description="Period unit")
34
+ __properties: ClassVar[List[str]] = ["id", "name", "currency", "price", "first_period_price", "period", "period_unit"]
35
+
36
+ @field_validator('period_unit')
37
+ def period_unit_validate_enum(cls, value):
38
+ """Validates the enum"""
39
+ if value is None:
40
+ return value
41
+
42
+ if value not in set(['day', 'week', 'month', 'year', 'none']):
43
+ raise ValueError("must be one of enum values ('day', 'week', 'month', 'year', 'none')")
44
+ return value
45
+
46
+ model_config = ConfigDict(
47
+ populate_by_name=True,
48
+ validate_assignment=True,
49
+ protected_namespaces=(),
50
+ )
51
+
52
+
53
+ def to_str(self) -> str:
54
+ """Returns the string representation of the model using alias"""
55
+ return pprint.pformat(self.model_dump(by_alias=True))
56
+
57
+ def to_json(self) -> str:
58
+ """Returns the JSON representation of the model using alias"""
59
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
+ return json.dumps(self.to_dict())
61
+
62
+ @classmethod
63
+ def from_json(cls, json_str: str) -> Optional[Self]:
64
+ """Create an instance of BillingV1CatalogCatalogItemPriceResource from a JSON string"""
65
+ return cls.from_dict(json.loads(json_str))
66
+
67
+ def to_dict(self) -> Dict[str, Any]:
68
+ """Return the dictionary representation of the model using alias.
69
+
70
+ This has the following differences from calling pydantic's
71
+ `self.model_dump(by_alias=True)`:
72
+
73
+ * `None` is only added to the output dict for nullable fields that
74
+ were set at model initialization. Other fields with value `None`
75
+ are ignored.
76
+ """
77
+ excluded_fields: Set[str] = set([
78
+ ])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of BillingV1CatalogCatalogItemPriceResource from a dict"""
90
+ if obj is None:
91
+ return None
92
+
93
+ if not isinstance(obj, dict):
94
+ return cls.model_validate(obj)
95
+
96
+ _obj = cls.model_validate({
97
+ "id": obj.get("id"),
98
+ "name": obj.get("name"),
99
+ "currency": obj.get("currency"),
100
+ "price": obj.get("price"),
101
+ "first_period_price": obj.get("first_period_price"),
102
+ "period": obj.get("period"),
103
+ "period_unit": obj.get("period_unit")
104
+ })
105
+ return _obj
106
+
107
+
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger API Python SDK
5
+
6
+ API Version: 0.0.1-beta
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
19
+ from typing import Any, ClassVar, Dict, List, Optional
20
+ from hostinger_api.models.billing_v1_catalog_catalog_item_price_resource import BillingV1CatalogCatalogItemPriceResource
21
+ from typing import Optional, Set
22
+ from typing_extensions import Self
23
+
24
+ class BillingV1CatalogCatalogItemResource(BaseModel):
25
+ """
26
+ BillingV1CatalogCatalogItemResource
27
+ """ # noqa: E501
28
+ id: Optional[StrictStr] = Field(default=None, description="Catalog item ID")
29
+ name: Optional[StrictStr] = None
30
+ category: Optional[StrictStr] = None
31
+ prices: Optional[List[BillingV1CatalogCatalogItemPriceResource]] = Field(default=None, description="Array of [`Billing.V1.Catalog.CatalogItemPriceResource`](#model/billingv1catalogcatalogitempriceresource)")
32
+ __properties: ClassVar[List[str]] = ["id", "name", "category", "prices"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of BillingV1CatalogCatalogItemResource from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of each item in prices (list)
74
+ _items = []
75
+ if self.prices:
76
+ for _item_prices in self.prices:
77
+ if _item_prices:
78
+ _items.append(_item_prices.to_dict())
79
+ _dict['prices'] = _items
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of BillingV1CatalogCatalogItemResource from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "id": obj.get("id"),
93
+ "name": obj.get("name"),
94
+ "category": obj.get("category"),
95
+ "prices": [BillingV1CatalogCatalogItemPriceResource.from_dict(_item) for _item in obj["prices"]] if obj.get("prices") is not None else None
96
+ })
97
+ return _obj
98
+
99
+
@@ -0,0 +1,145 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hostinger API Python SDK
5
+
6
+ API Version: 0.0.1-beta
7
+
8
+ NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
9
+ If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
10
+ """ # noqa: E501
11
+
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, StrictStr
19
+ from typing import Any, ClassVar, Dict, List, Optional
20
+ from typing import Optional, Set
21
+ from typing_extensions import Self
22
+
23
+ class BillingV1OrderOrderBillingAddressResource(BaseModel):
24
+ """
25
+ BillingV1OrderOrderBillingAddressResource
26
+ """ # noqa: E501
27
+ first_name: Optional[StrictStr] = None
28
+ last_name: Optional[StrictStr] = None
29
+ company: Optional[StrictStr] = None
30
+ address_1: Optional[StrictStr] = None
31
+ address_2: Optional[StrictStr] = None
32
+ city: Optional[StrictStr] = None
33
+ state: Optional[StrictStr] = None
34
+ zip: Optional[StrictStr] = None
35
+ country: Optional[StrictStr] = None
36
+ phone: Optional[StrictStr] = None
37
+ email: Optional[StrictStr] = None
38
+ __properties: ClassVar[List[str]] = ["first_name", "last_name", "company", "address_1", "address_2", "city", "state", "zip", "country", "phone", "email"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of BillingV1OrderOrderBillingAddressResource from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # set to None if company (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.company is None and "company" in self.model_fields_set:
82
+ _dict['company'] = None
83
+
84
+ # set to None if address_1 (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.address_1 is None and "address_1" in self.model_fields_set:
87
+ _dict['address_1'] = None
88
+
89
+ # set to None if address_2 (nullable) is None
90
+ # and model_fields_set contains the field
91
+ if self.address_2 is None and "address_2" in self.model_fields_set:
92
+ _dict['address_2'] = None
93
+
94
+ # set to None if city (nullable) is None
95
+ # and model_fields_set contains the field
96
+ if self.city is None and "city" in self.model_fields_set:
97
+ _dict['city'] = None
98
+
99
+ # set to None if state (nullable) is None
100
+ # and model_fields_set contains the field
101
+ if self.state is None and "state" in self.model_fields_set:
102
+ _dict['state'] = None
103
+
104
+ # set to None if zip (nullable) is None
105
+ # and model_fields_set contains the field
106
+ if self.zip is None and "zip" in self.model_fields_set:
107
+ _dict['zip'] = None
108
+
109
+ # set to None if country (nullable) is None
110
+ # and model_fields_set contains the field
111
+ if self.country is None and "country" in self.model_fields_set:
112
+ _dict['country'] = None
113
+
114
+ # set to None if phone (nullable) is None
115
+ # and model_fields_set contains the field
116
+ if self.phone is None and "phone" in self.model_fields_set:
117
+ _dict['phone'] = None
118
+
119
+ return _dict
120
+
121
+ @classmethod
122
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
123
+ """Create an instance of BillingV1OrderOrderBillingAddressResource from a dict"""
124
+ if obj is None:
125
+ return None
126
+
127
+ if not isinstance(obj, dict):
128
+ return cls.model_validate(obj)
129
+
130
+ _obj = cls.model_validate({
131
+ "first_name": obj.get("first_name"),
132
+ "last_name": obj.get("last_name"),
133
+ "company": obj.get("company"),
134
+ "address_1": obj.get("address_1"),
135
+ "address_2": obj.get("address_2"),
136
+ "city": obj.get("city"),
137
+ "state": obj.get("state"),
138
+ "zip": obj.get("zip"),
139
+ "country": obj.get("country"),
140
+ "phone": obj.get("phone"),
141
+ "email": obj.get("email")
142
+ })
143
+ return _obj
144
+
145
+