Skip to content

Commit 698ebf4

Browse files
Merge branch 'proj/maintenance-policy' into maintenance_test
2 parents c5f6185 + 39da1b5 commit 698ebf4

Some content is hidden

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

55 files changed

+4317
-266
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.1
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.1
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.1
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.1
1515
with:
1616
method: chat.postMessage
1717
token: ${{ secrets.SLACK_BOT_TOKEN }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ lint: build
5858
# TEST_CASE: Optional, specify a test case (e.g. 'test_image_replication')
5959
# TEST_ARGS: Optional, additional arguments for pytest (e.g. '-v' for verbose mode)
6060

61-
TEST_COMMAND = $(if $(TEST_SUITE),$(if $(filter $(TEST_SUITE),linode_client login_client),$(TEST_SUITE),models/$(TEST_SUITE)))
61+
TEST_COMMAND = $(if $(TEST_SUITE),$(if $(filter $(TEST_SUITE),linode_client login_client filters),$(TEST_SUITE),models/$(TEST_SUITE)))
6262

6363
.PHONY: test-int
6464
test-int:

linode_api4/groups/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .lke_tier import *
1212
from .longview import *
1313
from .maintenance import *
14+
from .monitor import *
1415
from .networking import *
1516
from .nodebalancer import *
1617
from .object_storage import *

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/monitor.py

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
__all__ = [
2+
"MonitorGroup",
3+
]
4+
from typing import Any, Optional
5+
6+
from linode_api4 import (
7+
PaginatedList,
8+
)
9+
from linode_api4.errors import UnexpectedResponseError
10+
from linode_api4.groups import Group
11+
from linode_api4.objects import (
12+
MonitorDashboard,
13+
MonitorMetricsDefinition,
14+
MonitorService,
15+
MonitorServiceToken,
16+
)
17+
18+
19+
class MonitorGroup(Group):
20+
"""
21+
Encapsulates Monitor-related methods of the :any:`LinodeClient`.
22+
23+
This group contains all features beneath the `/monitor` group in the API v4.
24+
"""
25+
26+
def dashboards(
27+
self, *filters, service_type: Optional[str] = None
28+
) -> PaginatedList:
29+
"""
30+
Returns a list of dashboards. If `service_type` is provided, it fetches dashboards
31+
for the specific service type. If None, it fetches all dashboards.
32+
33+
dashboards = client.monitor.dashboards()
34+
dashboard = client.load(MonitorDashboard, 1)
35+
dashboards_by_service = client.monitor.dashboards(service_type="dbaas")
36+
37+
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
38+
39+
API Documentation:
40+
- All Dashboards: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
41+
- Dashboards by Service: https://techdocs.akamai.com/linode-api/reference/get-dashboards
42+
43+
:param service_type: The service type to get dashboards for.
44+
:type service_type: Optional[str]
45+
:param filters: Any number of filters to apply to this query.
46+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
47+
for more details on filtering.
48+
49+
:returns: A list of Dashboards.
50+
:rtype: PaginatedList of Dashboard
51+
"""
52+
endpoint = (
53+
f"/monitor/services/{service_type}/dashboards"
54+
if service_type
55+
else "/monitor/dashboards"
56+
)
57+
58+
return self.client._get_and_filter(
59+
MonitorDashboard,
60+
*filters,
61+
endpoint=endpoint,
62+
)
63+
64+
def services(
65+
self,
66+
*filters,
67+
) -> PaginatedList:
68+
"""
69+
Lists services supported by ACLP.
70+
supported_services = client.monitor.services()
71+
service_details = client.monitor.load(MonitorService, "dbaas")
72+
73+
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
74+
75+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
76+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
77+
78+
:param filters: Any number of filters to apply to this query.
79+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
80+
for more details on filtering.
81+
82+
:returns: Lists monitor services
83+
:rtype: PaginatedList of the Services
84+
"""
85+
endpoint = "/monitor/services"
86+
87+
return self.client._get_and_filter(
88+
MonitorService,
89+
*filters,
90+
endpoint=endpoint,
91+
)
92+
93+
def metric_definitions(
94+
self, service_type: str, *filters
95+
) -> list[MonitorMetricsDefinition]:
96+
"""
97+
Returns metrics for a specific service type.
98+
99+
metrics = client.monitor.list_metric_definitions(service_type="dbaas")
100+
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
101+
102+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
103+
104+
:param service_type: The service type to get metrics for.
105+
:type service_type: str
106+
:param filters: Any number of filters to apply to this query.
107+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
108+
for more details on filtering.
109+
110+
:returns: Returns a List of metrics for a service
111+
:rtype: PaginatedList of metrics
112+
"""
113+
return self.client._get_and_filter(
114+
MonitorMetricsDefinition,
115+
*filters,
116+
endpoint=f"/monitor/services/{service_type}/metric-definitions",
117+
)
118+
119+
def create_token(
120+
self, service_type: str, entity_ids: list[Any]
121+
) -> MonitorServiceToken:
122+
"""
123+
Returns a JWE Token for a specific service type.
124+
token = client.monitor.create_token(service_type="dbaas", entity_ids=[1234])
125+
126+
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
127+
128+
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
129+
130+
:param service_type: The service type to create token for.
131+
:type service_type: str
132+
:param entity_ids: The list of entity IDs for which the token is valid.
133+
:type entity_ids: any
134+
135+
:returns: Returns a token for a service
136+
:rtype: str
137+
"""
138+
139+
params = {"entity_ids": entity_ids}
140+
141+
result = self.client.post(
142+
f"/monitor/services/{service_type}/token", data=params
143+
)
144+
145+
if "token" not in result:
146+
raise UnexpectedResponseError(
147+
"Unexpected response when creating token!", json=result
148+
)
149+
return MonitorServiceToken(token=result["token"])

linode_api4/groups/object_storage.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ObjectStorageCluster,
2222
ObjectStorageKeyPermission,
2323
ObjectStorageKeys,
24+
ObjectStorageQuota,
2425
)
2526
from linode_api4.util import drop_null_keys
2627

@@ -517,3 +518,18 @@ def object_url_create(
517518
)
518519

519520
return MappedObject(**result)
521+
522+
def quotas(self, *filters):
523+
"""
524+
Lists the active ObjectStorage-related quotas applied to your account.
525+
526+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-quotas
527+
528+
:param filters: Any number of filters to apply to this query.
529+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
530+
for more details on filtering.
531+
532+
:returns: A list of Object Storage Quotas that matched the query.
533+
:rtype: PaginatedList of ObjectStorageQuota
534+
"""
535+
return self.client._get_and_filter(ObjectStorageQuota, *filters)

linode_api4/linode_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
LKEGroup,
2121
LongviewGroup,
2222
MaintenanceGroup,
23+
MonitorGroup,
2324
NetworkingGroup,
2425
NodeBalancerGroup,
2526
ObjectStorageGroup,
@@ -150,10 +151,6 @@ def __init__(
150151
#: more information
151152
self.account = AccountGroup(self)
152153

153-
#: Access methods related to Maintenance Policies - see :any:`MaintenanceGroup` for
154-
#: more information
155-
self.maintenance = MaintenanceGroup(self)
156-
157154
#: Access methods related to networking on your account - see
158155
#: :any:`NetworkingGroup` for more information
159156
self.networking = NetworkingGroup(self)

0 commit comments

Comments
 (0)