Skip to content

Commit bcb66cb

Browse files
Annotate set fields as unordered (#390)
1 parent c8f4bd5 commit bcb66cb

File tree

12 files changed

+34
-22
lines changed

12 files changed

+34
-22
lines changed

linode_api4/objects/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Account(Base):
4343
"zip": Property(mutable=True),
4444
"address_2": Property(mutable=True),
4545
"tax_id": Property(mutable=True),
46-
"capabilities": Property(),
46+
"capabilities": Property(unordered=True),
4747
"credit_card": Property(),
4848
"active_promotions": Property(),
4949
"active_since": Property(),
@@ -670,5 +670,5 @@ class AccountAvailability(Base):
670670

671671
properties = {
672672
"region": Property(identifier=True),
673-
"unavailable": Property(),
673+
"unavailable": Property(unordered=True),
674674
}

linode_api4/objects/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(
3232
id_relationship=False,
3333
slug_relationship=False,
3434
nullable=False,
35+
unordered=False,
3536
json_object=None,
3637
):
3738
"""
@@ -50,6 +51,10 @@ def __init__(
5051
(This should be used on fields ending with '_id' only)
5152
slug_relationship - This property is a slug related for a given type.
5253
nullable - This property can be explicitly null on PUT requests.
54+
unordered - The order of this property is not significant.
55+
NOTE: This field is currently only for annotations purposes
56+
and does not influence any update or decoding/encoding logic.
57+
json_object - The JSONObject class this property should be decoded into.
5358
"""
5459
self.mutable = mutable
5560
self.identifier = identifier
@@ -60,6 +65,7 @@ def __init__(
6065
self.id_relationship = id_relationship
6166
self.slug_relationship = slug_relationship
6267
self.nullable = nullable
68+
self.unordered = unordered
6369
self.json_class = json_object
6470

6571

linode_api4/objects/database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class MySQLDatabase(Base):
129129
properties = {
130130
"id": Property(identifier=True),
131131
"label": Property(mutable=True),
132-
"allow_list": Property(mutable=True),
132+
"allow_list": Property(mutable=True, unordered=True),
133133
"backups": Property(derived_class=MySQLDatabaseBackup),
134134
"cluster_size": Property(),
135135
"created": Property(is_datetime=True),
@@ -262,7 +262,7 @@ class PostgreSQLDatabase(Base):
262262
properties = {
263263
"id": Property(identifier=True),
264264
"label": Property(mutable=True),
265-
"allow_list": Property(mutable=True),
265+
"allow_list": Property(mutable=True, unordered=True),
266266
"backups": Property(derived_class=PostgreSQLDatabaseBackup),
267267
"cluster_size": Property(),
268268
"created": Property(is_datetime=True),
@@ -404,7 +404,7 @@ class Database(Base):
404404
properties = {
405405
"id": Property(),
406406
"label": Property(),
407-
"allow_list": Property(),
407+
"allow_list": Property(unordered=True),
408408
"cluster_size": Property(),
409409
"created": Property(),
410410
"encrypted": Property(),

linode_api4/objects/domain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ class Domain(Base):
4949
"status": Property(mutable=True),
5050
"soa_email": Property(mutable=True),
5151
"retry_sec": Property(mutable=True),
52-
"master_ips": Property(mutable=True),
53-
"axfr_ips": Property(mutable=True),
52+
"master_ips": Property(mutable=True, unordered=True),
53+
"axfr_ips": Property(mutable=True, unordered=True),
5454
"expire_sec": Property(mutable=True),
5555
"refresh_sec": Property(mutable=True),
5656
"ttl_sec": Property(mutable=True),
5757
"records": Property(derived_class=DomainRecord),
5858
"type": Property(mutable=True),
59-
"tags": Property(mutable=True),
59+
"tags": Property(mutable=True, unordered=True),
6060
}
6161

6262
def record_create(self, record_type, **kwargs):

linode_api4/objects/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ class Image(Base):
2525
"vendor": Property(),
2626
"size": Property(),
2727
"deprecated": Property(),
28-
"capabilities": Property(),
28+
"capabilities": Property(
29+
unordered=True,
30+
),
2931
}

linode_api4/objects/linode.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,11 @@ class Instance(Base):
642642
"configs": Property(derived_class=Config),
643643
"type": Property(slug_relationship=Type),
644644
"backups": Property(mutable=True),
645-
"ipv4": Property(),
645+
"ipv4": Property(unordered=True),
646646
"ipv6": Property(),
647647
"hypervisor": Property(),
648648
"specs": Property(),
649-
"tags": Property(mutable=True),
649+
"tags": Property(mutable=True, unordered=True),
650650
"host_uuid": Property(),
651651
"watchdog_enabled": Property(mutable=True),
652652
"has_user_data": Property(),
@@ -1745,7 +1745,9 @@ class StackScript(Base):
17451745
"created": Property(is_datetime=True),
17461746
"deployments_active": Property(),
17471747
"script": Property(mutable=True),
1748-
"images": Property(mutable=True), # TODO make slug_relationship
1748+
"images": Property(
1749+
mutable=True, unordered=True
1750+
), # TODO make slug_relationship
17491751
"deployments_total": Property(),
17501752
"description": Property(mutable=True),
17511753
"updated": Property(is_datetime=True),

linode_api4/objects/lke.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class LKENodePool(DerivedBase):
7474
volatile=True
7575
), # this is formatted in _populate below
7676
"autoscaler": Property(mutable=True),
77-
"tags": Property(mutable=True),
77+
"tags": Property(mutable=True, unordered=True),
7878
}
7979

8080
def _populate(self, json):
@@ -121,7 +121,7 @@ class LKECluster(Base):
121121
"id": Property(identifier=True),
122122
"created": Property(is_datetime=True),
123123
"label": Property(mutable=True),
124-
"tags": Property(mutable=True),
124+
"tags": Property(mutable=True, unordered=True),
125125
"updated": Property(is_datetime=True),
126126
"region": Property(slug_relationship=Region),
127127
"k8s_version": Property(slug_relationship=KubeVersion, mutable=True),

linode_api4/objects/networking.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class IPv6Range(Base):
3434
"region": Property(slug_relationship=Region),
3535
"prefix": Property(),
3636
"route_target": Property(),
37-
"linodes": Property(),
37+
"linodes": Property(
38+
unordered=True,
39+
),
3840
"is_bgp": Property(),
3941
}
4042

@@ -151,7 +153,7 @@ class VLAN(Base):
151153
properties = {
152154
"label": Property(identifier=True),
153155
"created": Property(is_datetime=True),
154-
"linodes": Property(),
156+
"linodes": Property(unordered=True),
155157
"region": Property(slug_relationship=Region),
156158
}
157159

@@ -189,7 +191,7 @@ class Firewall(Base):
189191
properties = {
190192
"id": Property(identifier=True),
191193
"label": Property(mutable=True),
192-
"tags": Property(mutable=True),
194+
"tags": Property(mutable=True, unordered=True),
193195
"status": Property(mutable=True),
194196
"created": Property(is_datetime=True),
195197
"updated": Property(is_datetime=True),

linode_api4/objects/nodebalancer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class NodeBalancerNode(DerivedBase):
3434
"weight": Property(mutable=True),
3535
"mode": Property(mutable=True),
3636
"status": Property(),
37-
"tags": Property(mutable=True),
37+
"tags": Property(mutable=True, unordered=True),
3838
}
3939

4040
def __init__(self, client, id, parent_id, nodebalancer_id=None, json=None):
@@ -217,7 +217,7 @@ class NodeBalancer(Base):
217217
"region": Property(slug_relationship=Region),
218218
"configs": Property(derived_class=NodeBalancerConfig),
219219
"transfer": Property(),
220-
"tags": Property(mutable=True),
220+
"tags": Property(mutable=True, unordered=True),
221221
}
222222

223223
# create derived objects

linode_api4/objects/region.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Region(Base):
1818
properties = {
1919
"id": Property(identifier=True),
2020
"country": Property(),
21-
"capabilities": Property(),
21+
"capabilities": Property(unordered=True),
2222
"status": Property(),
2323
"resolvers": Property(),
2424
"label": Property(),

0 commit comments

Comments
 (0)