Skip to content

Commit 76d6341

Browse files
authored
Merge pull request #705 from linode/dev
Release v5.45.0
2 parents 416f7a9 + 3ccfd56 commit 76d6341

44 files changed

Lines changed: 3922 additions & 229 deletions

Some content is hidden

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

.github/workflows/e2e-test-pr.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ on:
22
pull_request:
33
workflow_dispatch:
44
inputs:
5+
run_aclp_logs_stream_tests:
6+
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
7+
required: false
8+
default: 'false'
9+
type: choice
10+
options:
11+
- 'true'
12+
- 'false'
513
run_db_fork_tests:
614
description: 'Set this parameter to "true" to run fork database related test cases'
715
required: false
@@ -104,7 +112,7 @@ jobs:
104112
run: |
105113
timestamp=$(date +'%Y%m%d%H%M')
106114
report_filename="${timestamp}_sdk_test_report.xml"
107-
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
115+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} RUN_ACLP_LOGS_STREAM_TESTS=${{ github.event.inputs.run_aclp_logs_stream_tests }} TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
108116
env:
109117
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
110118

.github/workflows/e2e-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ name: Integration Tests
33
on:
44
workflow_dispatch:
55
inputs:
6+
run_aclp_logs_stream_tests:
7+
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
8+
required: false
9+
default: 'false'
10+
type: choice
11+
options:
12+
- 'true'
13+
- 'false'
614
run_db_fork_tests:
715
description: 'Set this parameter to "true" to run fork database related test cases'
816
required: false
@@ -99,7 +107,7 @@ jobs:
99107
run: |
100108
timestamp=$(date +'%Y%m%d%H%M')
101109
report_filename="${timestamp}_sdk_test_report.xml"
102-
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_SUITE="${{ github.event.inputs.test_suite }}" TEST_ARGS="--junitxml=${report_filename}"
110+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} RUN_ACLP_LOGS_STREAM_TESTS=${{ github.event.inputs.run_aclp_logs_stream_tests }} TEST_SUITE="${{ github.event.inputs.test_suite }}" TEST_ARGS="--junitxml=${report_filename}"
103111
env:
104112
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
105113

conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
import sys
3+
4+
# Ensure the repo root is on sys.path so that `from test.unit.base import ...`
5+
# works regardless of which directory pytest is invoked from.
6+
sys.path.insert(0, os.path.dirname(__file__))

linode_api4/groups/linode.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def instance_create(
166166
kernel: Optional[str] = None,
167167
boot_size: Optional[int] = None,
168168
authorized_users: Optional[List[str]] = None,
169+
ipv4: Optional[List[str]] = None,
169170
**kwargs,
170171
):
171172
"""
@@ -355,6 +356,9 @@ def instance_create(
355356
:param boot_size: The size of the boot disk in MB. If provided, this will be used to create
356357
the boot disk for the Instance.
357358
:type boot_size: int
359+
:param ipv4: A list of reserved IPv4 addresses to assign to this Instance.
360+
NOTE: Reserved IP feature may not currently be available to all users.
361+
:type ipv4: list[str]
358362
359363
:returns: A new Instance object
360364
:rtype: Instance
@@ -401,6 +405,7 @@ def instance_create(
401405
"network_helper": network_helper,
402406
"kernel": kernel,
403407
"boot_size": boot_size,
408+
"ipv4": ipv4,
404409
}
405410

406411
params.update(kwargs)

linode_api4/groups/monitor.py

Lines changed: 214 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@
88
AlertDefinition,
99
AlertDefinitionEntity,
1010
AlertScope,
11+
LogsDestination,
12+
LogsDestinationType,
13+
LogsStream,
14+
LogsStreamStatus,
15+
LogsStreamType,
1116
MonitorDashboard,
1217
MonitorMetricsDefinition,
1318
MonitorService,
1419
MonitorServiceToken,
1520
)
21+
from linode_api4.objects.monitor import (
22+
AkamaiObjectStorageLogsDestinationDetails,
23+
CustomHTTPSLogsDestinationDetails,
24+
LogsStreamDetails,
25+
)
1626

1727
__all__ = [
1828
"MonitorGroup",
@@ -37,8 +47,6 @@ def dashboards(
3747
dashboard = client.load(MonitorDashboard, 1)
3848
dashboards_by_service = client.monitor.dashboards(service_type="dbaas")
3949
40-
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
41-
4250
API Documentation:
4351
- All Dashboards: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
4452
- Dashboards by Service: https://techdocs.akamai.com/linode-api/reference/get-dashboards
@@ -73,8 +81,6 @@ def services(
7381
supported_services = client.monitor.services()
7482
service_details = client.monitor.load(MonitorService, "dbaas")
7583
76-
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
77-
7884
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
7985
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
8086
@@ -100,7 +106,6 @@ def metric_definitions(
100106
Returns metrics for a specific service type.
101107
102108
metrics = client.monitor.list_metric_definitions(service_type="dbaas")
103-
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
104109
105110
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
106111
@@ -126,8 +131,6 @@ def create_token(
126131
Returns a JWE Token for a specific service type.
127132
token = client.monitor.create_token(service_type="dbaas", entity_ids=[1234])
128133
129-
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
130-
131134
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
132135
133136
:param service_type: The service type to create token for.
@@ -165,7 +168,6 @@ def alert_definitions(
165168
166169
alerts = client.monitor.alert_definitions()
167170
alerts_by_service = client.monitor.alert_definitions(service_type="dbaas")
168-
.. note:: This endpoint is in beta and requires using the v4beta base URL.
169171
170172
API Documentation:
171173
https://techdocs.akamai.com/linode-api/reference/get-alert-definitions
@@ -202,8 +204,6 @@ def alert_channels(self, *filters) -> PaginatedList:
202204
Examples:
203205
channels = client.monitor.alert_channels()
204206
205-
.. note:: This endpoint is in beta and requires using the v4beta base URL.
206-
207207
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels
208208
209209
:param filters: Optional filter expressions to apply to the collection.
@@ -232,8 +232,6 @@ def create_alert_definition(
232232
The alert definition configures when alerts are fired and which channels
233233
are notified.
234234
235-
.. note:: This endpoint is in beta and requires using the v4beta base URL.
236-
237235
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-alert-definition-for-service-type
238236
239237
:param service_type: Service type for which to create the alert definition
@@ -309,9 +307,7 @@ def alert_definition_entities(
309307
310308
This endpoint supports pagination fields (`page`, `page_size`) in the API.
311309
312-
.. note:: This endpoint is in beta and requires using the v4beta base URL.
313-
314-
API Documentation: TODO
310+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-definition-entities
315311
316312
:param service_type: Service type for the alert definition (e.g. `dbaas`).
317313
:type service_type: str
@@ -332,3 +328,206 @@ def alert_definition_entities(
332328
*filters,
333329
endpoint=endpoint,
334330
)
331+
332+
def destinations(self, *filters) -> PaginatedList:
333+
"""
334+
List available logs destinations.
335+
336+
Returns a paginated collection of :class:`LogsDestination` objects which
337+
describe logs destinations. By default, this method returns all available
338+
destinations; you can supply optional filter expressions to restrict
339+
the results, for example::
340+
341+
# Get destinations created by username and with id 111
342+
destinations = client.monitor.destinations(LogsDestination.created_by == "username",
343+
LogsDestination.id == 111)
344+
345+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-destinations
346+
347+
:param filters: Any number of filters to apply to this query.
348+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
349+
for more details on filtering.
350+
351+
:returns: A list of :class:`LogsDestination` objects matching the query.
352+
:rtype: PaginatedList of LogsDestination
353+
"""
354+
355+
return self.client._get_and_filter(LogsDestination, *filters)
356+
357+
def destination_create(
358+
self,
359+
label: str,
360+
type: Union[LogsDestinationType, str],
361+
details: Union[
362+
AkamaiObjectStorageLogsDestinationDetails,
363+
CustomHTTPSLogsDestinationDetails,
364+
],
365+
) -> LogsDestination:
366+
"""
367+
Creates a new :any:`LogsDestination` for logs on this account.
368+
369+
For an ``akamai_object_storage`` destination::
370+
371+
client = LinodeClient(TOKEN)
372+
373+
new_destination = client.monitor.destination_create(
374+
label="OBJ_logs_destination",
375+
type="akamai_object_storage",
376+
details=AkamaiObjectStorageLogsDestinationDetails(
377+
access_key_id="1ABCD23EFG4HIJKLMNO5",
378+
access_key_secret="1aB2CD3e4fgHi5JK6lmnop7qR8STU9VxYzabcdefHh",
379+
bucket_name="primary-bucket",
380+
host="primary-bucket-1.us-east-12.linodeobjects.com",
381+
path="audit-logs",
382+
)
383+
)
384+
385+
For a ``custom_https`` destination::
386+
387+
new_destination = client.monitor.destination_create(
388+
label="custom_logs_destination",
389+
type="custom_https",
390+
details=CustomHTTPSLogsDestinationDetails(
391+
endpoint_url="https://my-site.com/log-storage/basicAuth",
392+
authentication=DestinationAuthentication(
393+
type="basic",
394+
details=BasicAuthenticationDetails(
395+
basic_authentication_user="user",
396+
basic_authentication_password="pass",
397+
),
398+
),
399+
data_compression="gzip",
400+
content_type="application/json",
401+
)
402+
)
403+
404+
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-destination
405+
406+
:param label: The name for this logs destination.
407+
:type label: str
408+
:param type: The type of destination — ``akamai_object_storage`` or ``custom_https``.
409+
:type type: str or LogsDestinationType
410+
:param details: A typed details object matching the destination type.
411+
Use :class:`AkamaiObjectStorageLogsDestinationDetails` for
412+
``akamai_object_storage`` or :class:`CustomHTTPSLogsDestinationDetails`
413+
for ``custom_https``.
414+
:type details: AkamaiObjectStorageLogsDestinationDetails or CustomHTTPSLogsDestinationDetails
415+
416+
:returns: The newly created logs destination.
417+
:rtype: LogsDestination
418+
"""
419+
420+
params = {
421+
"label": label,
422+
"type": type,
423+
"details": details.dict,
424+
}
425+
426+
result = self.client.post("/monitor/streams/destinations", data=params)
427+
428+
if "id" not in result:
429+
raise UnexpectedResponseError(
430+
"Unexpected response when creating destination!",
431+
json=result,
432+
)
433+
434+
return LogsDestination(self.client, result["id"], result)
435+
436+
def streams(self, *filters) -> PaginatedList:
437+
"""
438+
List available logs streams.
439+
440+
Returns a paginated collection of :class:`LogsStream` objects which
441+
describe logs streams. By default, this method returns all available
442+
streams; you can supply optional filter expressions to restrict
443+
the results, for example::
444+
445+
# Get all streams with status ``provisioning``
446+
provisioning_streams = client.monitor.streams(LogsStream.status == "provisioning")
447+
448+
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-streams
449+
450+
:param filters: Any number of filters to apply to this query.
451+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
452+
for more details on filtering.
453+
:returns: A list of :class:`LogsStream` objects matching the query.
454+
:rtype: PaginatedList of LogsStream
455+
"""
456+
457+
return self.client._get_and_filter(LogsStream, *filters)
458+
459+
def stream_create(
460+
self,
461+
destinations: list[int],
462+
label: str,
463+
type: Union[LogsStreamType, str],
464+
status: Optional[Union[LogsStreamStatus, str]] = None,
465+
details: Optional[LogsStreamDetails] = None,
466+
) -> LogsStream:
467+
"""
468+
Creates a new :any:`LogsStream` for logs on this account. For example::
469+
470+
client = LinodeClient(TOKEN)
471+
472+
# audit_logs stream (no details required)
473+
new_stream = client.monitor.stream_create(
474+
destinations=[1234],
475+
label="Linode_services",
476+
status="active",
477+
type="audit_logs"
478+
)
479+
480+
# lke_audit_logs stream with specific clusters
481+
lke_stream = client.monitor.stream_create(
482+
destinations=[1234],
483+
label="LKE_audit_stream",
484+
type="lke_audit_logs",
485+
details=LogsStreamDetails(
486+
cluster_ids=[1111, 2222],
487+
is_auto_add_all_clusters_enabled=False,
488+
)
489+
)
490+
491+
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-stream
492+
493+
:param destinations: The unique identifier for the sync point that will receive logs data.
494+
Run the List destinations operation and store the id values for each applicable destination.
495+
At the moment only single destination is supported.
496+
:type destinations: list[int]
497+
:param label: The name of the stream. This is used for display purposes in Akamai Cloud Manager.
498+
:type label: str
499+
:param type: The type of stream — ``audit_logs`` for Linode control plane logs,
500+
or ``lke_audit_logs`` for LKE enterprise cluster audit logs.
501+
:type type: str or LogsStreamType
502+
:param status: (Optional) The availability status of the stream. Possible values are: ``active``, ``inactive``.
503+
Defaults to ``active``.
504+
:type status: str
505+
:param details: (Optional) Additional stream details. Only applicable for
506+
``lke_audit_logs`` streams. Omit for ``audit_logs`` streams.
507+
:type details: LogsStreamDetails
508+
509+
:returns: The newly created logs stream.
510+
:rtype: LogsStream
511+
"""
512+
513+
params = {
514+
"label": label,
515+
"type": type,
516+
"destinations": destinations,
517+
}
518+
519+
if status is not None:
520+
params["status"] = status
521+
522+
if details is not None:
523+
params["details"] = details.dict
524+
525+
result = self.client.post("/monitor/streams", data=params)
526+
527+
if "id" not in result:
528+
raise UnexpectedResponseError(
529+
"Unexpected response when creating logs stream!",
530+
json=result,
531+
)
532+
533+
return LogsStream(self.client, result["id"], result)

0 commit comments

Comments
 (0)