Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/e2e-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ on:
pull_request:
workflow_dispatch:
inputs:
run_aclp_logs_stream_tests:
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'
run_db_fork_tests:
description: 'Set this parameter to "true" to run fork database related test cases'
required: false
Expand Down Expand Up @@ -104,7 +112,7 @@ jobs:
run: |
timestamp=$(date +'%Y%m%d%H%M')
report_filename="${timestamp}_sdk_test_report.xml"
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 }}"
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 }}"
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name: Integration Tests
on:
workflow_dispatch:
inputs:
run_aclp_logs_stream_tests:
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'
run_db_fork_tests:
description: 'Set this parameter to "true" to run fork database related test cases'
required: false
Expand Down Expand Up @@ -99,7 +107,7 @@ jobs:
run: |
timestamp=$(date +'%Y%m%d%H%M')
report_filename="${timestamp}_sdk_test_report.xml"
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}"
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}"
env:
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}

Expand Down
229 changes: 214 additions & 15 deletions linode_api4/groups/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
AlertDefinition,
AlertDefinitionEntity,
AlertScope,
LogsDestination,
LogsDestinationType,
LogsStream,
LogsStreamStatus,
LogsStreamType,
MonitorDashboard,
MonitorMetricsDefinition,
MonitorService,
MonitorServiceToken,
)
from linode_api4.objects.monitor import (
AkamaiObjectStorageLogsDestinationDetails,
CustomHTTPSLogsDestinationDetails,
LogsStreamDetails,
)

__all__ = [
"MonitorGroup",
Expand All @@ -37,8 +47,6 @@ def dashboards(
dashboard = client.load(MonitorDashboard, 1)
dashboards_by_service = client.monitor.dashboards(service_type="dbaas")

.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

API Documentation:
- All Dashboards: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
- Dashboards by Service: https://techdocs.akamai.com/linode-api/reference/get-dashboards
Expand Down Expand Up @@ -73,8 +81,6 @@ def services(
supported_services = client.monitor.services()
service_details = client.monitor.load(MonitorService, "dbaas")

.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type

Expand All @@ -100,7 +106,6 @@ def metric_definitions(
Returns metrics for a specific service type.

metrics = client.monitor.list_metric_definitions(service_type="dbaas")
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information

Expand All @@ -126,8 +131,6 @@ def create_token(
Returns a JWE Token for a specific service type.
token = client.monitor.create_token(service_type="dbaas", entity_ids=[1234])

.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token

:param service_type: The service type to create token for.
Expand Down Expand Up @@ -165,7 +168,6 @@ def alert_definitions(

alerts = client.monitor.alert_definitions()
alerts_by_service = client.monitor.alert_definitions(service_type="dbaas")
.. note:: This endpoint is in beta and requires using the v4beta base URL.

API Documentation:
https://techdocs.akamai.com/linode-api/reference/get-alert-definitions
Expand Down Expand Up @@ -202,8 +204,6 @@ def alert_channels(self, *filters) -> PaginatedList:
Examples:
channels = client.monitor.alert_channels()

.. note:: This endpoint is in beta and requires using the v4beta base URL.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification-channels

:param filters: Optional filter expressions to apply to the collection.
Expand Down Expand Up @@ -232,8 +232,6 @@ def create_alert_definition(
The alert definition configures when alerts are fired and which channels
are notified.

.. note:: This endpoint is in beta and requires using the v4beta base URL.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-alert-definition-for-service-type

:param service_type: Service type for which to create the alert definition
Expand Down Expand Up @@ -309,9 +307,7 @@ def alert_definition_entities(

This endpoint supports pagination fields (`page`, `page_size`) in the API.

.. note:: This endpoint is in beta and requires using the v4beta base URL.

API Documentation: TODO
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert-definition-entities

:param service_type: Service type for the alert definition (e.g. `dbaas`).
:type service_type: str
Expand All @@ -332,3 +328,206 @@ def alert_definition_entities(
*filters,
endpoint=endpoint,
)

def destinations(self, *filters) -> PaginatedList:
"""
List available logs destinations.

Returns a paginated collection of :class:`LogsDestination` objects which
describe logs destinations. By default, this method returns all available
destinations; you can supply optional filter expressions to restrict
the results, for example::

# Get destinations created by username and with id 111
destinations = client.monitor.destinations(LogsDestination.created_by == "username",
LogsDestination.id == 111)

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-destinations

:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
for more details on filtering.

:returns: A list of :class:`LogsDestination` objects matching the query.
:rtype: PaginatedList of LogsDestination
"""

return self.client._get_and_filter(LogsDestination, *filters)

def destination_create(
self,
label: str,
type: Union[LogsDestinationType, str],
details: Union[
AkamaiObjectStorageLogsDestinationDetails,
CustomHTTPSLogsDestinationDetails,
],
) -> LogsDestination:
"""
Creates a new :any:`LogsDestination` for logs on this account.

For an ``akamai_object_storage`` destination::

client = LinodeClient(TOKEN)

new_destination = client.monitor.destination_create(
label="OBJ_logs_destination",
type="akamai_object_storage",
details=AkamaiObjectStorageLogsDestinationDetails(
access_key_id="1ABCD23EFG4HIJKLMNO5",
access_key_secret="1aB2CD3e4fgHi5JK6lmnop7qR8STU9VxYzabcdefHh",
bucket_name="primary-bucket",
host="primary-bucket-1.us-east-12.linodeobjects.com",
path="audit-logs",
)
)

For a ``custom_https`` destination::

new_destination = client.monitor.destination_create(
label="custom_logs_destination",
type="custom_https",
details=CustomHTTPSLogsDestinationDetails(
endpoint_url="https://my-site.com/log-storage/basicAuth",
authentication=DestinationAuthentication(
type="basic",
details=BasicAuthenticationDetails(
basic_authentication_user="user",
basic_authentication_password="pass",
),
),
data_compression="gzip",
content_type="application/json",
)
)

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-destination

:param label: The name for this logs destination.
:type label: str
:param type: The type of destination — ``akamai_object_storage`` or ``custom_https``.
:type type: str or LogsDestinationType
:param details: A typed details object matching the destination type.
Use :class:`AkamaiObjectStorageLogsDestinationDetails` for
``akamai_object_storage`` or :class:`CustomHTTPSLogsDestinationDetails`
for ``custom_https``.
:type details: AkamaiObjectStorageLogsDestinationDetails or CustomHTTPSLogsDestinationDetails

:returns: The newly created logs destination.
:rtype: LogsDestination
"""

params = {
"label": label,
"type": type,
"details": details.dict,
}

result = self.client.post("/monitor/streams/destinations", data=params)

if "id" not in result:
raise UnexpectedResponseError(
"Unexpected response when creating destination!",
json=result,
)

return LogsDestination(self.client, result["id"], result)

def streams(self, *filters) -> PaginatedList:
"""
List available logs streams.

Returns a paginated collection of :class:`LogsStream` objects which
describe logs streams. By default, this method returns all available
streams; you can supply optional filter expressions to restrict
the results, for example::

# Get all streams with status ``provisioning``
provisioning_streams = client.monitor.streams(LogsStream.status == "provisioning")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-streams

:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
for more details on filtering.
:returns: A list of :class:`LogsStream` objects matching the query.
:rtype: PaginatedList of LogsStream
"""

return self.client._get_and_filter(LogsStream, *filters)

def stream_create(
self,
destinations: list[int],
label: str,
type: Union[LogsStreamType, str],
status: Optional[Union[LogsStreamStatus, str]] = None,
details: Optional[LogsStreamDetails] = None,
) -> LogsStream:
"""
Creates a new :any:`LogsStream` for logs on this account. For example::

client = LinodeClient(TOKEN)

# audit_logs stream (no details required)
new_stream = client.monitor.stream_create(
destinations=[1234],
label="Linode_services",
status="active",
type="audit_logs"
)

# lke_audit_logs stream with specific clusters
lke_stream = client.monitor.stream_create(
destinations=[1234],
label="LKE_audit_stream",
type="lke_audit_logs",
details=LogsStreamDetails(
cluster_ids=[1111, 2222],
is_auto_add_all_clusters_enabled=False,
)
)

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-stream

:param destinations: The unique identifier for the sync point that will receive logs data.
Run the List destinations operation and store the id values for each applicable destination.
At the moment only single destination is supported.
:type destinations: list[int]
:param label: The name of the stream. This is used for display purposes in Akamai Cloud Manager.
:type label: str
:param type: The type of stream — ``audit_logs`` for Linode control plane logs,
or ``lke_audit_logs`` for LKE enterprise cluster audit logs.
:type type: str or LogsStreamType
:param status: (Optional) The availability status of the stream. Possible values are: ``active``, ``inactive``.
Defaults to ``active``.
:type status: str
:param details: (Optional) Additional stream details. Only applicable for
``lke_audit_logs`` streams. Omit for ``audit_logs`` streams.
:type details: LogsStreamDetails

:returns: The newly created logs stream.
:rtype: LogsStream
"""

params = {
"label": label,
"type": type,
"destinations": destinations,
}

if status is not None:
params["status"] = status

if details is not None:
params["details"] = details.dict

result = self.client.post("/monitor/streams", data=params)

if "id" not in result:
raise UnexpectedResponseError(
"Unexpected response when creating logs stream!",
json=result,
)

return LogsStream(self.client, result["id"], result)
2 changes: 1 addition & 1 deletion linode_api4/groups/object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def global_quotas(self, *filters):
"""
Lists the active account-level Object Storage quotas applied to your account.

API Documentation: TBD
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-global-quotas

:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
Expand Down
Loading
Loading