-
Notifications
You must be signed in to change notification settings - Fork 75
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
base: dev
Are you sure you want to change the base?
Conversation
@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
linode_api4.groups.monitor
@@ -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
linode_api4.objects.monitor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the group and object to include 'all'
@@ -0,0 +1,122 @@ | |||
import json |
Check notice
Code scanning / CodeQL
Unused import Note test
MetricDefinition, | ||
CreateToken, | ||
) | ||
from linode_api4 import LinodeClient,MySQLDatabase |
Check notice
Code scanning / CodeQL
Unused import Note test
CreateToken, | ||
) | ||
from linode_api4 import LinodeClient,MySQLDatabase | ||
import re |
Check notice
Code scanning / CodeQL
Unused import Note test
) | ||
from linode_api4 import LinodeClient,MySQLDatabase | ||
import re | ||
import time |
Check notice
Code scanning / CodeQL
Unused import Note test
test/unit/objects/monitor_test.py
Outdated
from test.unit.base import ClientBaseCase | ||
import datetime | ||
|
||
from linode_api4.objects import CreateToken |
Check notice
Code scanning / CodeQL
Unused import Note test
There was a problem hiding this 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?
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions in the base class can only be used when the API parses ID based on the header called 'X-Filter'. The ACLP APIs are not written in a way to recognise any additional headers like this, hence added a new method for ID
class Dashboard(Base): | ||
""" | ||
List dashboards: https://techdocs.akamai.com/linode-api/get-dashboards-all | ||
""" | ||
|
||
api_endpoint = "/monitor/dashboards/" | ||
properties = { | ||
"id": Property(identifier=True), | ||
"created": Property(is_datetime=True), | ||
"label": Property(), | ||
"service_type": Property(), | ||
"type": Property(), | ||
"widgets": Property(mutable=True), | ||
"updated": Property(is_datetime=True), | ||
|
||
} | ||
|
||
class DashboardsByID(Base): | ||
""" | ||
Get a dashboard: https://techdocs.akamai.com/linode-api/reference/get-dashboards-by-id | ||
""" | ||
|
||
|
||
properties = { | ||
"id": Property(identifier=True), | ||
"created": Property(is_datetime=True), | ||
"label": Property(), | ||
"service_type": Property(), | ||
"type": Property(), | ||
"widgets": Property(mutable=True), | ||
"updated": Property(is_datetime=True), | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these two be merged using an api_endpoint
like /monitor/dashboards/{id}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The /monitor/dashboards and /monitor/dashboards/{id} are implemented separately in the codebase. It does not expect the 'X-filter' header which I believe is mandatory for grouping it.
Co-authored-by: Lena Garber <[email protected]>
📝 Description
The PR adds Monitor API for ACLP Product
✔️ How to Test
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