-
Notifications
You must be signed in to change notification settings - Fork 76
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? |
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?
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'll have to sign all of you commits (make sure each commit has the green Verified
tag) before merging this PR. To save troubles in the end, I'd suggest to do it sooner than later. You can look for github official docs to add signatures to all your commits
Co-authored-by: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com>
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.
Thanks for addressing the comments! A few things to note:
def list_monitor_dashboards(self, *filters) -> list[MonitorDashboard]: | ||
""" | ||
Returns a list of dashboards. | ||
|
||
dashboards = client.monitor_service.list_monitor_dashboards() | ||
dashboard = client.load(MonitorDashboard, 1) | ||
|
||
.. 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-all | ||
|
||
: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 Dashboards. | ||
:rtype: PaginatedList of Dashboard | ||
""" | ||
|
||
return self.client._get_and_filter(MonitorDashboard, *filters) | ||
|
||
def list_dashboards_by_service( | ||
self, service_type: str, *filters | ||
) -> list[MonitorDashboard]: | ||
""" | ||
Returns a list of dashboards for a particular service. | ||
|
||
dashboard_by_service = client.monitor_service.list_dashboards_by_service(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-dashboards | ||
|
||
:param service_type: The service type to get dashboards for. | ||
:type service_type: str | ||
: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: Dashboards filtered by Service Type. | ||
:rtype: PaginatedList of the Dashboards | ||
""" | ||
|
||
return self.client._get_and_filter( | ||
MonitorDashboard, | ||
*filters, | ||
endpoint=f"/monitor/services/{service_type}/dashboards", | ||
) |
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.
I wonder if it makes more sense to combine these two functions, since they're serving the same purpose to list dashboards and returning the same type.
How about we just having one function dashboards(...)
, and take an optional parameter service_type
? In this case if service_type
is provided by user, we will call the listing dashboards by service_type endpoint; if not, we will can the basic listing endpoint. The function header should looks like:
def dashborads(
self, service_type: Optional[str], *filters
) -> PaginatedList:
# implement the two endpoints
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.
We could have one function but both the endpoints have different implementation and fall under different api_endpoint group, so it could be misleading.
for dashboards we have - /monitor/dashboards/{id}
for service dashboard - /monitor/services/{service_type}/dashboards
return self.client._get_and_filter( | ||
MonitorService, | ||
*filters, | ||
endpoint=f"/monitor/services/{service_type}", |
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.
I checked the api doc, and it looks GET /monitor/services/{service_type}
is not a listing endpoint
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.
This endpoint should ideally return the details about a service. But the return type is a list.
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.
Oh interesting, do you mean that even GET /monitor/services/{service_type}
supposed to get a single service, but the response is a list, right?
class MonitorService(Base): | ||
""" | ||
Represents a single service type. | ||
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services | ||
|
||
""" | ||
|
||
api_endpoint = "/monitor/services/{service_type}" | ||
id_attribute = "service_type" | ||
properties = { | ||
"service_type": Property(ServiceType, identifier=True), | ||
"label": Property(), | ||
} |
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.
Since GET /monitor/services/{service_type}
returns a list, it can't be populated by the default _api_get() in Base. I think you can build MonitorService
into a JSONObject
as well, so user won't accidentally try to get this object from default approach
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 to JSONObject
linode_api4/groups/monitor.py
Outdated
:param service_type: The service type to create token for. | ||
:type service_type: str | ||
:param entity_ids: The list of entity IDs for which the token is valid. | ||
:type entity_ids: list of int |
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.
It seems entity_ids
is not necessary a list of int and could be any id types based on the linodego change: linode/linodego#746 Can you make the change and test it correspondingly as well?
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 type to Any
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.
Nice work, tests passed locally! Just change the entity_ids
type then should be good to go
📝 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