Skip to content

adding SDK changes for ACLP APIs #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Conversation

pmajali
Copy link

@pmajali pmajali commented Apr 11, 2025

📝 Description

The PR adds Monitor API for ACLP Product

✔️ How to Test

import os
import logging
from linode_api4 import LinodeClient

logger = logging.getLogger(__name__)

client = LinodeClient(os.environ.get("MY_PERSONAL_ACCESS_TOKEN"))
client.base_url = "https://api.linode.com/v4beta"


print("Listing services supported by ACLP")
services = client.monitor.supported_services()
for service in services:
        print("Label:", service.label)

How do I run the relevant unit/integration tests?

Run unit test as follows
pytest test/unit

Run integration test as follows
make testint TEST_SUITE=monitor

@pmajali pmajali requested a review from a team as a code owner April 11, 2025 06:20
@pmajali pmajali requested review from jriddle-linode and lgarber-akamai and removed request for a team April 11, 2025 06:20
@lgarber-akamai lgarber-akamai added the new-feature for new features in the changelog. label Apr 11, 2025
@yec-akamai
Copy link
Contributor

@pmajali Thank you for starting contributing to python SDK! Do you mind filling the PR description and test steps?

@@ -21,3 +21,4 @@
from .tag import *
from .volume import *
from .vpc import *
from .monitor import *

Check notice

Code scanning / CodeQL

'import *' may pollute namespace Note

Import pollutes the enclosing namespace, as the imported module
linode_api4.groups.monitor
does not define '__all__'.
@@ -21,3 +21,4 @@
from .vpc import *
from .beta import *
from .placement import *
from .monitor import *

Check notice

Code scanning / CodeQL

'import *' may pollute namespace Note

Import pollutes the enclosing namespace, as the imported module
linode_api4.objects.monitor
does not define '__all__'.
@@ -0,0 +1,122 @@
import json

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'json' is not used.
MetricDefinition,
CreateToken,
)
from linode_api4 import LinodeClient,MySQLDatabase

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'MySQLDatabase' is not used.
CreateToken,
)
from linode_api4 import LinodeClient,MySQLDatabase
import re

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 're' is not used.
)
from linode_api4 import LinodeClient,MySQLDatabase
import re
import time

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'time' is not used.
from test.unit.base import ClientBaseCase
import datetime

from linode_api4.objects import CreateToken

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'CreateToken' is not used.
@yec-akamai yec-akamai self-requested a review April 18, 2025 15:27
Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the PR given the suggestion from code scanning?

Comment on lines +42 to +63
def dashboard_by_ID(self, dashboard_id: int, *filters):
"""
Returns a dashboards on your account based on the ID passed.

.. 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-dashboards-by-id

: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 Dashboards.
:rtype: PaginatedList of the Dashboard
"""
result = self.client.get(f"/monitor/dashboards/{dashboard_id}")

if not "id" in result:
raise UnexpectedResponseError(
"Unexpected response when getting Dashboard!", json=result
)
return DashboardsByID(self.client, result["id"], result)
Copy link
Contributor

@yec-akamai yec-akamai Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to explicitly implement the get by id method in the group. If you read through the Base class for object, you can find each object has inherited some basic functions, i.e. get, set, delete, etc. Can you please update your PR to match the codebase standard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature for new features in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants