-
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? |
@@ -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'
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?
@@ -10,6 +10,7 @@ | |||
from .lke import * | |||
from .lke_tier import * | |||
from .longview import * | |||
from .monitor import * |
Check notice
Code scanning / CodeQL
'import *' may pollute namespace Note
linode_api4.groups.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.
To address this issue, I'd suggest to change the namespace to a less general one, i.e., monitor_service
.
@@ -10,6 +10,7 @@ | |||
from .lke import * | |||
from .lke_tier import * | |||
from .longview import * | |||
from .monitor import * |
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.
To address this issue, I'd suggest to change the namespace to a less general one, i.e., monitor_service
.
class DashboardByService(Base): | ||
""" | ||
Get a dashboard: https://techdocs.akamai.com/linode-api/reference/get-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), | ||
} |
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 object seems has the exact same properties as Dashboard
. It's not necessary to create a separate class here
""" | ||
|
||
return self.client._get_and_filter( | ||
DashboardByService, |
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 return type can be Dashboard
This group contains all features beneath the `/monitor` group in the API v4. | ||
""" | ||
|
||
def dashboards(self, *filters): |
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 explicitly declare the return type please? Same for all functions in this PR
from linode_api4.objects import Base, Property | ||
|
||
|
||
class Dashboard(Base): |
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 add a brief description to each class please?
class MetricDefinition(Base): | ||
""" | ||
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information | ||
""" | ||
|
||
id_attribute = "metric" | ||
properties = { | ||
"available_aggregate_functions": Property(), | ||
"dimensions": Property(mutable=True), | ||
"label": Property(), | ||
"is_alertable": Property(), | ||
"metric": Property(), | ||
"metric_type": Property(), | ||
"scrape_interval": Property(), | ||
"unit": 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.
It seems there is not an endpoint for getting a single metric. In this case, I think we can build it as an json object instead of class. Also personally i think it'd be better to name this type as ServiceMetric
class MetricDefinition(Base): | |
""" | |
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information | |
""" | |
id_attribute = "metric" | |
properties = { | |
"available_aggregate_functions": Property(), | |
"dimensions": Property(mutable=True), | |
"label": Property(), | |
"is_alertable": Property(), | |
"metric": Property(), | |
"metric_type": Property(), | |
"scrape_interval": Property(), | |
"unit": Property(), | |
} | |
class ServiceMetric(JSONObject): | |
# .. declare the attributes and their corresponding types | |
class CreateToken(Base): | ||
""" | ||
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token | ||
""" | ||
|
||
properties = {"token": Property(mutable=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.
This class is not necessary to have. You can build a MetricServiceToken
as a JSONObject
endpoint=f"/monitor/services/{service_type}/metric-definitions", | ||
) | ||
|
||
def create_token(self, service_type: str, entity_ids: list, *filters): |
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.
filter
is not needed since it's a post endpoint
:param filters: Any number of filters to apply to this query. | ||
See :doc:`Filtering Collections</linode_api4/objects/filtering>` | ||
for more details on filtering. | ||
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 better describe the params needed?
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.
There are many properties that are enums in the objects. Can you build them as StrEnum
, like we did in the linodego https://github.com/linode/linodego/pull/722/files?
Plus, it might be good to align the naming with lindoego too
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
📝 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