Skip to content

Commit db07c7f

Browse files
Fix merge conflicts
2 parents eedfece + 06f8a5f commit db07c7f

File tree

77 files changed

+6512
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6512
-125
lines changed

.github/workflows/e2e-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ jobs:
232232
steps:
233233
- name: Notify Slack
234234
id: main_message
235-
uses: slackapi/slack-github-action@v2.0.0
235+
uses: slackapi/slack-github-action@v2.1.0
236236
with:
237237
method: chat.postMessage
238238
token: ${{ secrets.SLACK_BOT_TOKEN }}
@@ -264,7 +264,7 @@ jobs:
264264
265265
- name: Test summary thread
266266
if: success()
267-
uses: slackapi/slack-github-action@v2.0.0
267+
uses: slackapi/slack-github-action@v2.1.0
268268
with:
269269
method: chat.postMessage
270270
token: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/nightly-smoke-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
- name: Notify Slack
4747
if: always() && github.repository == 'linode/linode_api4-python'
48-
uses: slackapi/slack-github-action@v2.0.0
48+
uses: slackapi/slack-github-action@v2.1.0
4949
with:
5050
method: chat.postMessage
5151
token: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/publish-pypi.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ on:
55
types: [ published ]
66
jobs:
77
pypi-release:
8+
permissions:
9+
# IMPORTANT: this permission is mandatory for trusted publishing
10+
id-token: write
811
runs-on: ubuntu-latest
12+
environment: pypi-release
913
steps:
1014
- name: Checkout
1115
uses: actions/checkout@v4
@@ -25,5 +29,3 @@ jobs:
2529

2630
- name: Publish the release artifacts to PyPI
2731
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # pin@release/v1.12.4
28-
with:
29-
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release-notify-slack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- name: Notify Slack - Main Message
1313
id: main_message
14-
uses: slackapi/slack-github-action@v2.0.0
14+
uses: slackapi/slack-github-action@v2.1.0
1515
with:
1616
method: chat.postMessage
1717
token: ${{ secrets.SLACK_BOT_TOKEN }}

linode_api4/groups/database.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from typing import Any, Dict, Union
2+
3+
from linode_api4 import (
4+
MySQLDatabaseConfigOptions,
5+
PostgreSQLDatabaseConfigOptions,
6+
)
17
from linode_api4.errors import UnexpectedResponseError
28
from linode_api4.groups import Group
39
from linode_api4.objects import (
@@ -63,6 +69,26 @@ def engines(self, *filters):
6369
"""
6470
return self.client._get_and_filter(DatabaseEngine, *filters)
6571

72+
def mysql_config_options(self):
73+
"""
74+
Returns a detailed list of all the configuration options for MySQL Databases.
75+
76+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-mysql-config
77+
78+
:returns: The JSON configuration options for MySQL Databases.
79+
"""
80+
return self.client.get("/databases/mysql/config", model=self)
81+
82+
def postgresql_config_options(self):
83+
"""
84+
Returns a detailed list of all the configuration options for PostgreSQL Databases.
85+
86+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-postgresql-config
87+
88+
:returns: The JSON configuration options for PostgreSQL Databases.
89+
"""
90+
return self.client.get("/databases/postgresql/config", model=self)
91+
6692
def instances(self, *filters):
6793
"""
6894
Returns a list of Managed Databases active on this account.
@@ -93,7 +119,15 @@ def mysql_instances(self, *filters):
93119
"""
94120
return self.client._get_and_filter(MySQLDatabase, *filters)
95121

96-
def mysql_create(self, label, region, engine, ltype, **kwargs):
122+
def mysql_create(
123+
self,
124+
label,
125+
region,
126+
engine,
127+
ltype,
128+
engine_config: Union[MySQLDatabaseConfigOptions, Dict[str, Any]] = None,
129+
**kwargs,
130+
):
97131
"""
98132
Creates an :any:`MySQLDatabase` on this account with
99133
the given label, region, engine, and node type. For example::
@@ -123,13 +157,16 @@ def mysql_create(self, label, region, engine, ltype, **kwargs):
123157
:type engine: str or Engine
124158
:param ltype: The Linode Type to use for this cluster
125159
:type ltype: str or Type
160+
:param engine_config: The configuration options for this MySQL cluster
161+
:type engine_config: Dict[str, Any] or MySQLDatabaseConfigOptions
126162
"""
127163

128164
params = {
129165
"label": label,
130166
"region": region,
131167
"engine": engine,
132168
"type": ltype,
169+
"engine_config": engine_config,
133170
}
134171
params.update(kwargs)
135172

@@ -216,7 +253,17 @@ def postgresql_instances(self, *filters):
216253
"""
217254
return self.client._get_and_filter(PostgreSQLDatabase, *filters)
218255

219-
def postgresql_create(self, label, region, engine, ltype, **kwargs):
256+
def postgresql_create(
257+
self,
258+
label,
259+
region,
260+
engine,
261+
ltype,
262+
engine_config: Union[
263+
PostgreSQLDatabaseConfigOptions, Dict[str, Any]
264+
] = None,
265+
**kwargs,
266+
):
220267
"""
221268
Creates an :any:`PostgreSQLDatabase` on this account with
222269
the given label, region, engine, and node type. For example::
@@ -246,13 +293,16 @@ def postgresql_create(self, label, region, engine, ltype, **kwargs):
246293
:type engine: str or Engine
247294
:param ltype: The Linode Type to use for this cluster
248295
:type ltype: str or Type
296+
:param engine_config: The configuration options for this PostgreSQL cluster
297+
:type engine_config: Dict[str, Any] or PostgreSQLDatabaseConfigOptions
249298
"""
250299

251300
params = {
252301
"label": label,
253302
"region": region,
254303
"engine": engine,
255304
"type": ltype,
305+
"engine_config": engine_config,
256306
}
257307
params.update(kwargs)
258308

linode_api4/groups/linode.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import base64
22
import os
3-
from collections.abc import Iterable
4-
from typing import Any, Dict, Optional, Union
3+
from typing import Any, Dict, List, Optional, Union
54

65
from linode_api4.common import load_and_validate_keys
76
from linode_api4.errors import UnexpectedResponseError
87
from linode_api4.groups import Group
98
from linode_api4.objects import (
10-
ConfigInterface,
119
Firewall,
1210
Instance,
1311
InstanceDiskEncryptionType,
@@ -21,8 +19,13 @@
2119
from linode_api4.objects.linode import (
2220
Backup,
2321
InstancePlacementGroupAssignment,
22+
InterfaceGeneration,
23+
NetworkInterface,
2424
_expand_placement_group_assignment,
2525
)
26+
from linode_api4.objects.linode_interfaces import (
27+
LinodeInterfaceOptions,
28+
)
2629
from linode_api4.util import drop_null_keys
2730

2831

@@ -153,6 +156,13 @@ def instance_create(
153156
int,
154157
]
155158
] = None,
159+
interfaces: Optional[
160+
List[
161+
Union[LinodeInterfaceOptions, NetworkInterface, Dict[str, Any]],
162+
]
163+
] = None,
164+
interface_generation: Optional[Union[InterfaceGeneration, str]] = None,
165+
network_helper: Optional[bool] = None,
156166
**kwargs,
157167
):
158168
"""
@@ -230,6 +240,30 @@ def instance_create(
230240
"us-east",
231241
backup=snapshot)
232242
243+
**Create an Instance with explicit interfaces:**
244+
245+
To create a new Instance with explicit interfaces, provide list of
246+
LinodeInterfaceOptions objects or dicts to the "interfaces" field::
247+
248+
linode, password = client.linode.instance_create(
249+
"g6-standard-1",
250+
"us-mia",
251+
image="linode/ubuntu24.04",
252+
253+
# This can be configured as an account-wide default
254+
interface_generation=InterfaceGeneration.LINODE,
255+
256+
interfaces=[
257+
LinodeInterfaceOptions(
258+
default_route=LinodeInterfaceDefaultRouteOptions(
259+
ipv4=True,
260+
ipv6=True
261+
),
262+
public=LinodeInterfacePublicOptions
263+
)
264+
]
265+
)
266+
233267
**Create an empty Instance**
234268
235269
If you want to create an empty Instance that you will configure manually,
@@ -293,9 +327,13 @@ def instance_create(
293327
:type disk_encryption: InstanceDiskEncryptionType or str
294328
:param interfaces: An array of Network Interfaces to add to this Linode’s Configuration Profile.
295329
At least one and up to three Interface objects can exist in this array.
296-
:type interfaces: list[ConfigInterface] or list[dict[str, Any]]
330+
:type interfaces: List[LinodeInterfaceOptions], List[NetworkInterface], or List[dict[str, Any]]
297331
:param placement_group: A Placement Group to create this Linode under.
298332
:type placement_group: Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]
333+
:param interface_generation: The generation of network interfaces this Linode uses.
334+
:type interface_generation: InterfaceGeneration or str
335+
:param network_helper: Whether this instance should have Network Helper enabled.
336+
:type network_helper: bool
299337
300338
:returns: A new Instance object, or a tuple containing the new Instance and
301339
the generated password.
@@ -311,13 +349,6 @@ def instance_create(
311349
ret_pass = Instance.generate_root_password()
312350
kwargs["root_pass"] = ret_pass
313351

314-
interfaces = kwargs.get("interfaces", None)
315-
if interfaces is not None and isinstance(interfaces, Iterable):
316-
kwargs["interfaces"] = [
317-
i._serialize() if isinstance(i, ConfigInterface) else i
318-
for i in interfaces
319-
]
320-
321352
params = {
322353
"type": ltype,
323354
"region": region,
@@ -336,6 +367,9 @@ def instance_create(
336367
if placement_group
337368
else None
338369
),
370+
"interfaces": interfaces,
371+
"interface_generation": interface_generation,
372+
"network_helper": network_helper,
339373
}
340374

341375
params.update(kwargs)

0 commit comments

Comments
 (0)