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