Skip to content

Commit de4a736

Browse files
authored
Merge branch 'dev' into feat/DPS-44447-Add-endpoint-to-expose-streams-limit-per-account-
2 parents 3fbfdeb + 4e05452 commit de4a736

33 files changed

Lines changed: 559 additions & 144 deletions

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ jobs:
6767
python-version: ${{ matrix.python-version }}
6868
- name: Run tests
6969
run: |
70-
pip install ".[test]"
71-
tox
70+
pip install ".[unit-test]"
71+
make test-unit

‎AGENTS.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
## Source of Truth
44

55
- This is the official synchronous Python SDK for the Linode API. Supported
6-
Python versions come from [pyproject.toml](pyproject.toml) (`>=3.10`); do not
7-
infer support from the older environment names still present in [tox.ini](tox.ini).
6+
Python versions come from [pyproject.toml](pyproject.toml) (`>=3.10`).
87
- Make changes only in canonical source trees such as `linode_api4/`, `test/`,
98
`docs/`, `examples/`, and `.github/`. Do not edit generated copies or output in
109
`build/`, `dist/`, `docs/build/`, `docs/_build/`, or `linode_api4.egg-info/`.

‎README.rst‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,13 @@ Tests
102102
-----
103103

104104
Tests live in the ``test`` directory. When invoking tests, make sure you are
105-
in the root directory of this project. To run the full suite across all
106-
supported python versions, use tox_:
105+
in the root directory of this project. Install unit-test dependencies and run
106+
the mocked unit suite with:
107107

108108
.. code-block:: shell
109109
110-
tox
111-
112-
Running tox also runs pylint and coverage reports.
110+
python3 -m pip install -e ".[unit-test]"
111+
make test-unit
113112
114113
The test suite uses fixtures stored as JSON in ``test/fixtures``. These files
115114
contain sanitized JSON responses from the API - the file name is the URL called
@@ -131,8 +130,6 @@ from the api base url that should be returned, for example::
131130
linode = self.client.linode.instance_create('g6-standard-2', 'us-east')
132131
self.assertEqual(linode.id, 123) # passes
133132

134-
.. _tox: http://tox.readthedocs.io
135-
136133

137134
Integration Tests
138135
-----------------

‎linode_api4/groups/nodebalancer.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ def create(self, region, **kwargs):
3535
:param ipv4: A reserved IPv4 address to assign to this NodeBalancer.
3636
NOTE: Reserved IP feature may not currently be available to all users.
3737
:type ipv4: str
38+
:param type: The NodeBalancer type. Supported values include
39+
``common``, ``premium``, ``premium_40gb``, and
40+
``enterprise``. This cannot be changed after creation.
41+
NOTE: Creating premium or enterprise NodeBalancers may not
42+
currently be available to all users.
43+
:type type: str
44+
:param backend_connectivity: How this NodeBalancer communicates with
45+
backends (``legacy``, ``ipv6``, or ``vpc``). If omitted,
46+
the API infers a value from ``vpcs`` or config nodes, or
47+
returns ``undefined`` until the first node is added.
48+
``undefined`` cannot be sent by clients. This cannot be
49+
changed after creation.
50+
NOTE: This field may not currently be available to all users.
51+
:type backend_connectivity: NodeBalancerBackendConnectivity | str
52+
:param vpcs: VPC attachments for this NodeBalancer. Required when
53+
``backend_connectivity`` is ``vpc``.
54+
:type vpcs: list[dict]
55+
:param configs: NodeBalancer configs and optional nodes to create
56+
with this NodeBalancer. Node addresses must match the
57+
selected or inferred backend connectivity.
58+
:type configs: list[dict]
3859
3960
:returns: The new NodeBalancer
4061
:rtype: NodeBalancer

‎linode_api4/objects/linode.py‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,42 @@ class UpgradeInterfacesResult(JSONObject):
790790
)
791791

792792

793+
@dataclass
794+
class InstanceBackupSchedule(JSONObject):
795+
"""
796+
InstanceBackupSchedule represents when automatic backups of a Linode Instance are taken.
797+
"""
798+
799+
include_none_values = True
800+
801+
day: Optional[str] = None
802+
window: Optional[str] = None
803+
804+
805+
@dataclass
806+
class InstanceBackupsOptions(JSONObject):
807+
"""
808+
InstanceBackupsOptions is used to update the backup settings of a Linode Instance.
809+
"""
810+
811+
enabled: bool = False
812+
schedule: Optional[InstanceBackupSchedule] = None
813+
814+
815+
@dataclass
816+
class InstanceBackups(JSONObject):
817+
"""
818+
InstanceBackups represents the backup settings and status of a Linode Instance.
819+
"""
820+
821+
put_class = InstanceBackupsOptions
822+
823+
enabled: bool = False
824+
available: bool = False
825+
schedule: Optional[InstanceBackupSchedule] = None
826+
last_successful: Optional[str] = None
827+
828+
793829
class Instance(Base):
794830
"""
795831
A Linode Instance.
@@ -811,7 +847,7 @@ class Instance(Base):
811847
"disks": Property(derived_class=Disk),
812848
"configs": Property(derived_class=Config),
813849
"type": Property(slug_relationship=Type),
814-
"backups": Property(mutable=True),
850+
"backups": Property(mutable=True, json_object=InstanceBackups),
815851
"ipv4": Property(unordered=True),
816852
"ipv6": Property(),
817853
"hypervisor": Property(),

‎linode_api4/objects/monitor.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ class MonitorDashboard(Base):
277277
"id": Property(identifier=True),
278278
"created": Property(is_datetime=True),
279279
"label": Property(),
280-
"service_type": Property(ServiceType),
281-
"type": Property(DashboardType),
280+
"service_type": Property(),
281+
"type": Property(),
282282
"group_by": Property(),
283283
"widgets": Property(json_object=DashboardWidget),
284284
"updated": Property(is_datetime=True),
@@ -295,7 +295,7 @@ class MonitorService(Base):
295295
api_endpoint = "/monitor/services/{service_type}"
296296
id_attribute = "service_type"
297297
properties = {
298-
"service_type": Property(ServiceType),
298+
"service_type": Property(),
299299
"label": Property(),
300300
"alert": Property(json_object=ServiceAlert),
301301
}
@@ -496,7 +496,7 @@ class AlertDefinition(DerivedBase):
496496
"entity_ids": Property(mutable=True),
497497
"description": Property(mutable=True),
498498
"service_class": Property(alias_of="class"),
499-
"scope": Property(AlertScope),
499+
"scope": Property(),
500500
"regions": Property(mutable=True),
501501
"entities": Property(json_object=AlertEntities),
502502
"channel_ids": Property(mutable=True),

‎linode_api4/objects/nodebalancer.py‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
from linode_api4.objects.dbase import DerivedBase
88
from linode_api4.objects.networking import Firewall, IPAddress
99
from linode_api4.objects.region import Region
10+
from linode_api4.objects.serializable import StrEnum
11+
12+
13+
class NodeBalancerBackendConnectivity(StrEnum):
14+
"""Backend connectivity modes accepted when creating a NodeBalancer."""
15+
16+
IPV6 = "ipv6"
17+
LEGACY = "legacy"
18+
UNDEFINED = "undefined"
19+
VPC = "vpc"
1020

1121

1222
class NodeBalancerType(Base):
@@ -162,8 +172,10 @@ def node_create(self, label, address, **kwargs):
162172
163173
API documentation: https://techdocs.akamai.com/linode-api/reference/post-node-balancer-node
164174
165-
:param address: The private IP Address where this backend can be reached.
166-
This must be a private IP address.
175+
:param address: The address and port where this backend can be reached.
176+
The address may be a private IPv4 address, a public
177+
IPv6 address, or a VPC address. The address type must
178+
match this NodeBalancer's ``backend_connectivity``.
167179
:type address: str
168180
169181
:param label: The label for this node. This is for display purposes only.
@@ -255,6 +267,9 @@ class NodeBalancer(Base):
255267
"tags": Property(mutable=True, unordered=True),
256268
"client_udp_sess_throttle": Property(mutable=True),
257269
"locks": Property(unordered=True),
270+
"type": Property(),
271+
"backend_connectivity": Property(),
272+
"backend_ipv6_prefix": Property(),
258273
}
259274

260275
# create derived objects

‎pyproject.toml‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,38 @@ dependencies = ["requests", "polling", "deprecated"]
3535
dynamic = ["version"]
3636

3737
[project.optional-dependencies]
38-
test = ["tox>=4.4.0"]
39-
40-
dev = [
41-
"tox>=4.4.0",
42-
"mock>=5.0.0",
38+
test-shared = [
4339
"pytest>=7.3.1",
4440
"httpretty>=1.1.4",
41+
"pytest-rerunfailures",
42+
]
43+
unit-test = [
44+
"linode_api4[test-shared]",
45+
"mock>=5.0.0",
46+
]
47+
int-test = [
48+
"linode_api4[test-shared]",
49+
"cryptography",
50+
]
51+
lint = [
4552
"black>=23.1.0",
4653
"isort>=5.12.0",
4754
"autoflake>=2.0.1",
4855
"pylint",
4956
"twine>=4.0.2",
5057
"build>=0.10.0",
51-
"Sphinx>=6.0.0",
52-
"sphinx-autobuild>=2021.3.14",
53-
"sphinxcontrib-fulltoc>=1.2.0",
54-
"build>=0.10.0",
55-
"twine>=4.0.2",
56-
"pytest-rerunfailures",
5758
]
58-
5959
doc = [
6060
"Sphinx>=6.0.0",
6161
"sphinx-autobuild>=2021.3.14",
6262
"sphinxcontrib-fulltoc>=1.2.0",
6363
]
64+
dev = [
65+
"linode_api4[unit-test]",
66+
"linode_api4[int-test]",
67+
"linode_api4[lint]",
68+
"linode_api4[doc]",
69+
]
6470

6571
[project.urls]
6672
Homepage = "https://github.com/linode/linode_api4-python"

‎test/fixtures/linode_instances.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"label": "linode123",
2020
"backups": {
2121
"enabled": true,
22+
"available": true,
23+
"last_successful": "2018-01-01T00:01:01",
2224
"schedule": {
2325
"window": "W02",
2426
"day": "Scheduling"

‎test/fixtures/linode_instances_123_nodebalancers.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"ipv4": "203.0.113.1",
99
"ipv6": null,
1010
"label": "balancer12345",
11+
"type": "premium",
12+
"backend_connectivity": "ipv6",
13+
"backend_ipv6_prefix": "2600:3c22:1:20:0:3039::/96",
1114
"region": "us-east",
1215
"tags": [
1316
"example tag",

0 commit comments

Comments
 (0)