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,190 @@
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 datetime import datetime
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_ipv4 import VPSV1VirtualMachineVirtualMachineResourceIpv4
22
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_ipv6 import VPSV1VirtualMachineVirtualMachineResourceIpv6
23
+ from hostinger_api.models.vpsv1_virtual_machine_virtual_machine_resource_template import VPSV1VirtualMachineVirtualMachineResourceTemplate
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class VPSV1VirtualMachineVirtualMachineResource(BaseModel):
28
+ """
29
+ VPSV1VirtualMachineVirtualMachineResource
30
+ """ # noqa: E501
31
+ id: Optional[StrictInt] = Field(default=None, description="Virtual machine ID")
32
+ firewall_group_id: Optional[StrictInt] = Field(default=None, description="Active firewall ID, `null` if disabled")
33
+ subscription_id: Optional[StrictStr] = Field(default=None, description="Subscription ID")
34
+ plan: Optional[StrictStr] = Field(default=None, description="VPS plan name")
35
+ hostname: Optional[StrictStr] = None
36
+ state: Optional[StrictStr] = None
37
+ actions_lock: Optional[StrictStr] = None
38
+ cpus: Optional[StrictInt] = Field(default=None, description="CPUs count assigned to virtual machine")
39
+ memory: Optional[StrictInt] = Field(default=None, description="Memory available to virtual machine (in megabytes)")
40
+ disk: Optional[StrictInt] = Field(default=None, description="Virtual machine disk size (in megabytes)")
41
+ bandwidth: Optional[StrictInt] = Field(default=None, description="Monthly internet traffic available to virtual machine (in megabytes)")
42
+ ns1: Optional[StrictStr] = Field(default=None, description="Primary DNS resolver")
43
+ ns2: Optional[StrictStr] = Field(default=None, description="Secondary DNS resolver")
44
+ ipv4: Optional[VPSV1VirtualMachineVirtualMachineResourceIpv4] = None
45
+ ipv6: Optional[VPSV1VirtualMachineVirtualMachineResourceIpv6] = None
46
+ template: Optional[VPSV1VirtualMachineVirtualMachineResourceTemplate] = None
47
+ created_at: Optional[datetime] = None
48
+ __properties: ClassVar[List[str]] = ["id", "firewall_group_id", "subscription_id", "plan", "hostname", "state", "actions_lock", "cpus", "memory", "disk", "bandwidth", "ns1", "ns2", "ipv4", "ipv6", "template", "created_at"]
49
+
50
+ @field_validator('state')
51
+ def state_validate_enum(cls, value):
52
+ """Validates the enum"""
53
+ if value is None:
54
+ return value
55
+
56
+ if value not in set(['running', 'stopped', 'creating', 'initial']):
57
+ raise ValueError("must be one of enum values ('running', 'stopped', 'creating', 'initial')")
58
+ return value
59
+
60
+ @field_validator('actions_lock')
61
+ def actions_lock_validate_enum(cls, value):
62
+ """Validates the enum"""
63
+ if value is None:
64
+ return value
65
+
66
+ if value not in set(['unlocked', 'locked']):
67
+ raise ValueError("must be one of enum values ('unlocked', 'locked')")
68
+ return value
69
+
70
+ model_config = ConfigDict(
71
+ populate_by_name=True,
72
+ validate_assignment=True,
73
+ protected_namespaces=(),
74
+ )
75
+
76
+
77
+ def to_str(self) -> str:
78
+ """Returns the string representation of the model using alias"""
79
+ return pprint.pformat(self.model_dump(by_alias=True))
80
+
81
+ def to_json(self) -> str:
82
+ """Returns the JSON representation of the model using alias"""
83
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
84
+ return json.dumps(self.to_dict())
85
+
86
+ @classmethod
87
+ def from_json(cls, json_str: str) -> Optional[Self]:
88
+ """Create an instance of VPSV1VirtualMachineVirtualMachineResource from a JSON string"""
89
+ return cls.from_dict(json.loads(json_str))
90
+
91
+ def to_dict(self) -> Dict[str, Any]:
92
+ """Return the dictionary representation of the model using alias.
93
+
94
+ This has the following differences from calling pydantic's
95
+ `self.model_dump(by_alias=True)`:
96
+
97
+ * `None` is only added to the output dict for nullable fields that
98
+ were set at model initialization. Other fields with value `None`
99
+ are ignored.
100
+ """
101
+ excluded_fields: Set[str] = set([
102
+ ])
103
+
104
+ _dict = self.model_dump(
105
+ by_alias=True,
106
+ exclude=excluded_fields,
107
+ exclude_none=True,
108
+ )
109
+ # override the default output from pydantic by calling `to_dict()` of ipv4
110
+ if self.ipv4:
111
+ _dict['ipv4'] = self.ipv4.to_dict()
112
+ # override the default output from pydantic by calling `to_dict()` of ipv6
113
+ if self.ipv6:
114
+ _dict['ipv6'] = self.ipv6.to_dict()
115
+ # override the default output from pydantic by calling `to_dict()` of template
116
+ if self.template:
117
+ _dict['template'] = self.template.to_dict()
118
+ # set to None if firewall_group_id (nullable) is None
119
+ # and model_fields_set contains the field
120
+ if self.firewall_group_id is None and "firewall_group_id" in self.model_fields_set:
121
+ _dict['firewall_group_id'] = None
122
+
123
+ # set to None if subscription_id (nullable) is None
124
+ # and model_fields_set contains the field
125
+ if self.subscription_id is None and "subscription_id" in self.model_fields_set:
126
+ _dict['subscription_id'] = None
127
+
128
+ # set to None if plan (nullable) is None
129
+ # and model_fields_set contains the field
130
+ if self.plan is None and "plan" in self.model_fields_set:
131
+ _dict['plan'] = None
132
+
133
+ # set to None if ns1 (nullable) is None
134
+ # and model_fields_set contains the field
135
+ if self.ns1 is None and "ns1" in self.model_fields_set:
136
+ _dict['ns1'] = None
137
+
138
+ # set to None if ns2 (nullable) is None
139
+ # and model_fields_set contains the field
140
+ if self.ns2 is None and "ns2" in self.model_fields_set:
141
+ _dict['ns2'] = None
142
+
143
+ # set to None if ipv4 (nullable) is None
144
+ # and model_fields_set contains the field
145
+ if self.ipv4 is None and "ipv4" in self.model_fields_set:
146
+ _dict['ipv4'] = None
147
+
148
+ # set to None if ipv6 (nullable) is None
149
+ # and model_fields_set contains the field
150
+ if self.ipv6 is None and "ipv6" in self.model_fields_set:
151
+ _dict['ipv6'] = None
152
+
153
+ # set to None if template (nullable) is None
154
+ # and model_fields_set contains the field
155
+ if self.template is None and "template" in self.model_fields_set:
156
+ _dict['template'] = None
157
+
158
+ return _dict
159
+
160
+ @classmethod
161
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
162
+ """Create an instance of VPSV1VirtualMachineVirtualMachineResource from a dict"""
163
+ if obj is None:
164
+ return None
165
+
166
+ if not isinstance(obj, dict):
167
+ return cls.model_validate(obj)
168
+
169
+ _obj = cls.model_validate({
170
+ "id": obj.get("id"),
171
+ "firewall_group_id": obj.get("firewall_group_id"),
172
+ "subscription_id": obj.get("subscription_id"),
173
+ "plan": obj.get("plan"),
174
+ "hostname": obj.get("hostname"),
175
+ "state": obj.get("state"),
176
+ "actions_lock": obj.get("actions_lock"),
177
+ "cpus": obj.get("cpus"),
178
+ "memory": obj.get("memory"),
179
+ "disk": obj.get("disk"),
180
+ "bandwidth": obj.get("bandwidth"),
181
+ "ns1": obj.get("ns1"),
182
+ "ns2": obj.get("ns2"),
183
+ "ipv4": VPSV1VirtualMachineVirtualMachineResourceIpv4.from_dict(obj["ipv4"]) if obj.get("ipv4") is not None else None,
184
+ "ipv6": VPSV1VirtualMachineVirtualMachineResourceIpv6.from_dict(obj["ipv6"]) if obj.get("ipv6") is not None else None,
185
+ "template": VPSV1VirtualMachineVirtualMachineResourceTemplate.from_dict(obj["template"]) if obj.get("template") is not None else None,
186
+ "created_at": obj.get("created_at")
187
+ })
188
+ return _obj
189
+
190
+
@@ -0,0 +1,131 @@
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 json
15
+ import pprint
16
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
17
+ from typing import Any, List, Optional
18
+ from hostinger_api.models.vpsv1_ip_address_ip_address_resource import VPSV1IPAddressIPAddressResource
19
+ from pydantic import StrictStr, Field
20
+ from typing import Union, List, Set, Optional, Dict
21
+ from typing_extensions import Literal, Self
22
+
23
+ VPSV1VIRTUALMACHINEVIRTUALMACHINERESOURCEIPV4_ONE_OF_SCHEMAS = ["List[VPSV1IPAddressIPAddressResource]"]
24
+
25
+ class VPSV1VirtualMachineVirtualMachineResourceIpv4(BaseModel):
26
+ """
27
+ IPv4 address of virtual machine
28
+ """
29
+ # data type: List[VPSV1IPAddressIPAddressResource]
30
+ oneof_schema_1_validator: Optional[List[VPSV1IPAddressIPAddressResource]] = Field(default=None, description="Array of [`VPS.V1.IPAddress.IPAddressResource`](#model/vpsv1ipaddressipaddressresource)")
31
+ actual_instance: Optional[Union[List[VPSV1IPAddressIPAddressResource]]] = None
32
+ one_of_schemas: Set[str] = { "List[VPSV1IPAddressIPAddressResource]" }
33
+
34
+ model_config = ConfigDict(
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def __init__(self, *args, **kwargs) -> None:
41
+ if args:
42
+ if len(args) > 1:
43
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
44
+ if kwargs:
45
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
46
+ super().__init__(actual_instance=args[0])
47
+ else:
48
+ super().__init__(**kwargs)
49
+
50
+ @field_validator('actual_instance')
51
+ def actual_instance_must_validate_oneof(cls, v):
52
+ if v is None:
53
+ return v
54
+
55
+ instance = VPSV1VirtualMachineVirtualMachineResourceIpv4.model_construct()
56
+ error_messages = []
57
+ match = 0
58
+ # validate data type: List[VPSV1IPAddressIPAddressResource]
59
+ try:
60
+ instance.oneof_schema_1_validator = v
61
+ match += 1
62
+ except (ValidationError, ValueError) as e:
63
+ error_messages.append(str(e))
64
+ if match > 1:
65
+ # more than 1 match
66
+ raise ValueError("Multiple matches found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceIpv4 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
67
+ elif match == 0:
68
+ # no match
69
+ raise ValueError("No match found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceIpv4 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
70
+ else:
71
+ return v
72
+
73
+ @classmethod
74
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
75
+ return cls.from_json(json.dumps(obj))
76
+
77
+ @classmethod
78
+ def from_json(cls, json_str: Optional[str]) -> Self:
79
+ """Returns the object represented by the json string"""
80
+ instance = cls.model_construct()
81
+ if json_str is None:
82
+ return instance
83
+
84
+ error_messages = []
85
+ match = 0
86
+
87
+ # deserialize data into List[VPSV1IPAddressIPAddressResource]
88
+ try:
89
+ # validation
90
+ instance.oneof_schema_1_validator = json.loads(json_str)
91
+ # assign value to actual_instance
92
+ instance.actual_instance = instance.oneof_schema_1_validator
93
+ match += 1
94
+ except (ValidationError, ValueError) as e:
95
+ error_messages.append(str(e))
96
+
97
+ if match > 1:
98
+ # more than 1 match
99
+ raise ValueError("Multiple matches found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceIpv4 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
100
+ elif match == 0:
101
+ # no match
102
+ raise ValueError("No match found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceIpv4 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
103
+ else:
104
+ return instance
105
+
106
+ def to_json(self) -> str:
107
+ """Returns the JSON representation of the actual instance"""
108
+ if self.actual_instance is None:
109
+ return "null"
110
+
111
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
112
+ return self.actual_instance.to_json()
113
+ else:
114
+ return json.dumps(self.actual_instance)
115
+
116
+ def to_dict(self) -> Optional[Union[Dict[str, Any], List[VPSV1IPAddressIPAddressResource]]]:
117
+ """Returns the dict representation of the actual instance"""
118
+ if self.actual_instance is None:
119
+ return None
120
+
121
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
122
+ return self.actual_instance.to_dict()
123
+ else:
124
+ # primitive type
125
+ return self.actual_instance
126
+
127
+ def to_str(self) -> str:
128
+ """Returns the string representation of the actual instance"""
129
+ return pprint.pformat(self.model_dump())
130
+
131
+
@@ -0,0 +1,131 @@
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 json
15
+ import pprint
16
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
17
+ from typing import Any, List, Optional
18
+ from hostinger_api.models.vpsv1_ip_address_ip_address_resource import VPSV1IPAddressIPAddressResource
19
+ from pydantic import StrictStr, Field
20
+ from typing import Union, List, Set, Optional, Dict
21
+ from typing_extensions import Literal, Self
22
+
23
+ VPSV1VIRTUALMACHINEVIRTUALMACHINERESOURCEIPV6_ONE_OF_SCHEMAS = ["List[VPSV1IPAddressIPAddressResource]"]
24
+
25
+ class VPSV1VirtualMachineVirtualMachineResourceIpv6(BaseModel):
26
+ """
27
+ IPv6 address of virtual machine, `null` if not assigned
28
+ """
29
+ # data type: List[VPSV1IPAddressIPAddressResource]
30
+ oneof_schema_1_validator: Optional[List[VPSV1IPAddressIPAddressResource]] = Field(default=None, description="Array of [`VPS.V1.IPAddress.IPAddressResource`](#model/vpsv1ipaddressipaddressresource)")
31
+ actual_instance: Optional[Union[List[VPSV1IPAddressIPAddressResource]]] = None
32
+ one_of_schemas: Set[str] = { "List[VPSV1IPAddressIPAddressResource]" }
33
+
34
+ model_config = ConfigDict(
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def __init__(self, *args, **kwargs) -> None:
41
+ if args:
42
+ if len(args) > 1:
43
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
44
+ if kwargs:
45
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
46
+ super().__init__(actual_instance=args[0])
47
+ else:
48
+ super().__init__(**kwargs)
49
+
50
+ @field_validator('actual_instance')
51
+ def actual_instance_must_validate_oneof(cls, v):
52
+ if v is None:
53
+ return v
54
+
55
+ instance = VPSV1VirtualMachineVirtualMachineResourceIpv6.model_construct()
56
+ error_messages = []
57
+ match = 0
58
+ # validate data type: List[VPSV1IPAddressIPAddressResource]
59
+ try:
60
+ instance.oneof_schema_1_validator = v
61
+ match += 1
62
+ except (ValidationError, ValueError) as e:
63
+ error_messages.append(str(e))
64
+ if match > 1:
65
+ # more than 1 match
66
+ raise ValueError("Multiple matches found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceIpv6 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
67
+ elif match == 0:
68
+ # no match
69
+ raise ValueError("No match found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceIpv6 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
70
+ else:
71
+ return v
72
+
73
+ @classmethod
74
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
75
+ return cls.from_json(json.dumps(obj))
76
+
77
+ @classmethod
78
+ def from_json(cls, json_str: Optional[str]) -> Self:
79
+ """Returns the object represented by the json string"""
80
+ instance = cls.model_construct()
81
+ if json_str is None:
82
+ return instance
83
+
84
+ error_messages = []
85
+ match = 0
86
+
87
+ # deserialize data into List[VPSV1IPAddressIPAddressResource]
88
+ try:
89
+ # validation
90
+ instance.oneof_schema_1_validator = json.loads(json_str)
91
+ # assign value to actual_instance
92
+ instance.actual_instance = instance.oneof_schema_1_validator
93
+ match += 1
94
+ except (ValidationError, ValueError) as e:
95
+ error_messages.append(str(e))
96
+
97
+ if match > 1:
98
+ # more than 1 match
99
+ raise ValueError("Multiple matches found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceIpv6 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
100
+ elif match == 0:
101
+ # no match
102
+ raise ValueError("No match found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceIpv6 with oneOf schemas: List[VPSV1IPAddressIPAddressResource]. Details: " + ", ".join(error_messages))
103
+ else:
104
+ return instance
105
+
106
+ def to_json(self) -> str:
107
+ """Returns the JSON representation of the actual instance"""
108
+ if self.actual_instance is None:
109
+ return "null"
110
+
111
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
112
+ return self.actual_instance.to_json()
113
+ else:
114
+ return json.dumps(self.actual_instance)
115
+
116
+ def to_dict(self) -> Optional[Union[Dict[str, Any], List[VPSV1IPAddressIPAddressResource]]]:
117
+ """Returns the dict representation of the actual instance"""
118
+ if self.actual_instance is None:
119
+ return None
120
+
121
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
122
+ return self.actual_instance.to_dict()
123
+ else:
124
+ # primitive type
125
+ return self.actual_instance
126
+
127
+ def to_str(self) -> str:
128
+ """Returns the string representation of the actual instance"""
129
+ return pprint.pformat(self.model_dump())
130
+
131
+
@@ -0,0 +1,127 @@
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 json
15
+ import pprint
16
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
17
+ from typing import Any, List, Optional
18
+ from hostinger_api.models.vpsv1_template_template_resource import VPSV1TemplateTemplateResource
19
+ from pydantic import StrictStr, Field
20
+ from typing import Union, List, Set, Optional, Dict
21
+ from typing_extensions import Literal, Self
22
+
23
+ VPSV1VIRTUALMACHINEVIRTUALMACHINERESOURCETEMPLATE_ONE_OF_SCHEMAS = ["VPSV1TemplateTemplateResource"]
24
+
25
+ class VPSV1VirtualMachineVirtualMachineResourceTemplate(BaseModel):
26
+ """
27
+ OS template installed in virtual machine
28
+ """
29
+ # data type: VPSV1TemplateTemplateResource
30
+ oneof_schema_1_validator: Optional[VPSV1TemplateTemplateResource] = None
31
+ actual_instance: Optional[Union[VPSV1TemplateTemplateResource]] = None
32
+ one_of_schemas: Set[str] = { "VPSV1TemplateTemplateResource" }
33
+
34
+ model_config = ConfigDict(
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def __init__(self, *args, **kwargs) -> None:
41
+ if args:
42
+ if len(args) > 1:
43
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
44
+ if kwargs:
45
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
46
+ super().__init__(actual_instance=args[0])
47
+ else:
48
+ super().__init__(**kwargs)
49
+
50
+ @field_validator('actual_instance')
51
+ def actual_instance_must_validate_oneof(cls, v):
52
+ if v is None:
53
+ return v
54
+
55
+ instance = VPSV1VirtualMachineVirtualMachineResourceTemplate.model_construct()
56
+ error_messages = []
57
+ match = 0
58
+ # validate data type: VPSV1TemplateTemplateResource
59
+ if not isinstance(v, VPSV1TemplateTemplateResource):
60
+ error_messages.append(f"Error! Input type `{type(v)}` is not `VPSV1TemplateTemplateResource`")
61
+ else:
62
+ match += 1
63
+ if match > 1:
64
+ # more than 1 match
65
+ raise ValueError("Multiple matches found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceTemplate with oneOf schemas: VPSV1TemplateTemplateResource. Details: " + ", ".join(error_messages))
66
+ elif match == 0:
67
+ # no match
68
+ raise ValueError("No match found when setting `actual_instance` in VPSV1VirtualMachineVirtualMachineResourceTemplate with oneOf schemas: VPSV1TemplateTemplateResource. Details: " + ", ".join(error_messages))
69
+ else:
70
+ return v
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
74
+ return cls.from_json(json.dumps(obj))
75
+
76
+ @classmethod
77
+ def from_json(cls, json_str: Optional[str]) -> Self:
78
+ """Returns the object represented by the json string"""
79
+ instance = cls.model_construct()
80
+ if json_str is None:
81
+ return instance
82
+
83
+ error_messages = []
84
+ match = 0
85
+
86
+ # deserialize data into VPSV1TemplateTemplateResource
87
+ try:
88
+ instance.actual_instance = VPSV1TemplateTemplateResource.from_json(json_str)
89
+ match += 1
90
+ except (ValidationError, ValueError) as e:
91
+ error_messages.append(str(e))
92
+
93
+ if match > 1:
94
+ # more than 1 match
95
+ raise ValueError("Multiple matches found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceTemplate with oneOf schemas: VPSV1TemplateTemplateResource. Details: " + ", ".join(error_messages))
96
+ elif match == 0:
97
+ # no match
98
+ raise ValueError("No match found when deserializing the JSON string into VPSV1VirtualMachineVirtualMachineResourceTemplate with oneOf schemas: VPSV1TemplateTemplateResource. Details: " + ", ".join(error_messages))
99
+ else:
100
+ return instance
101
+
102
+ def to_json(self) -> str:
103
+ """Returns the JSON representation of the actual instance"""
104
+ if self.actual_instance is None:
105
+ return "null"
106
+
107
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
108
+ return self.actual_instance.to_json()
109
+ else:
110
+ return json.dumps(self.actual_instance)
111
+
112
+ def to_dict(self) -> Optional[Union[Dict[str, Any], VPSV1TemplateTemplateResource]]:
113
+ """Returns the dict representation of the actual instance"""
114
+ if self.actual_instance is None:
115
+ return None
116
+
117
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
118
+ return self.actual_instance.to_dict()
119
+ else:
120
+ # primitive type
121
+ return self.actual_instance
122
+
123
+ def to_str(self) -> str:
124
+ """Returns the string representation of the actual instance"""
125
+ return pprint.pformat(self.model_dump())
126
+
127
+
hostinger_api/py.typed ADDED
File without changes