Skip to content

Commit fe4a6bd

Browse files
committed
updating with make format changes
1 parent 7b8348b commit fe4a6bd

File tree

4 files changed

+92
-95
lines changed

4 files changed

+92
-95
lines changed

linode_api4/groups/monitor.py

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class MonitorGroup(Group):
2424

2525
def dashboards(self, *filters):
2626
"""
27-
Returns a list of dashboards on your account.
27+
Returns a list of dashboards on your account.
2828
2929
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
30-
30+
3131
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards-all
3232
3333
:param filters: Any number of filters to apply to this query.
@@ -39,14 +39,12 @@ def dashboards(self, *filters):
3939
"""
4040
return self.client._get_and_filter(Dashboard, *filters)
4141

42-
43-
4442
def dashboards_by_service(self, service_type: str, *filters):
4543
"""
46-
Returns a dashboards on your account based on the service passed.
44+
Returns a dashboards on your account based on the service passed.
4745
4846
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
49-
47+
5048
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-dashboards
5149
5250
:param filters: Any number of filters to apply to this query.
@@ -56,20 +54,19 @@ def dashboards_by_service(self, service_type: str, *filters):
5654
:returns: A Dashboards filtered by Service Type.
5755
:rtype: PaginatedList of the Dashboards
5856
"""
59-
57+
6058
return self.client._get_and_filter(
6159
DashboardByService,
6260
*filters,
6361
endpoint=f"/monitor/services/{service_type}/dashboards",
6462
)
6563

66-
6764
def supported_services(self, *filters):
6865
"""
69-
Returns a list of services supported by ACLP.
66+
Returns a list of services supported by ACLP.
7067
7168
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
72-
69+
7370
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
7471
7572
:param filters: Any number of filters to apply to this query.
@@ -82,54 +79,54 @@ def supported_services(self, *filters):
8279

8380
return self.client._get_and_filter(MonitorServiceSupported, *filters)
8481

85-
def details_by_service(self, service_type: str,*filters):
82+
def details_by_service(self, service_type: str, *filters):
8683
"""
87-
Returns a details about a particular service.
84+
Returns a details about a particular service.
8885
8986
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
90-
87+
9188
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
9289
9390
:param filters: Any number of filters to apply to this query.
9491
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
9592
for more details on filtering.
9693
9794
:returns: Details about a Supported Services
98-
:rtype: PaginatedList of the Service
95+
:rtype: PaginatedList of the Service
9996
"""
10097
return self.client._get_and_filter(
10198
ServiceDetails,
10299
*filters,
103100
endpoint=f"/monitor/services/{service_type}",
104101
)
105-
106-
def metric_definitions(self, service_type: str,*filters):
102+
103+
def metric_definitions(self, service_type: str, *filters):
107104
"""
108-
Returns metrics for a specific service type.
105+
Returns metrics for a specific service type.
109106
110107
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
111-
108+
112109
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
113110
114111
:param filters: Any number of filters to apply to this query.
115112
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
116113
for more details on filtering.
117114
118115
:returns: Returns a List of metrics for a service
119-
:rtype: PaginatedList of metrics
116+
:rtype: PaginatedList of metrics
120117
"""
121118
return self.client._get_and_filter(
122119
MetricDefinition,
123120
*filters,
124121
endpoint=f"/monitor/services/{service_type}/metric-definitions",
125122
)
126-
123+
127124
def create_token(self, service_type: str, entity_ids: list, *filters):
128125
"""
129-
Returns a JWE Token for a specific service type.
126+
Returns a JWE Token for a specific service type.
130127
131128
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
132-
129+
133130
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
134131
:param filters: Any number of filters to apply to this query.
135132
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
@@ -141,20 +138,12 @@ def create_token(self, service_type: str, entity_ids: list, *filters):
141138

142139
params = {"entity_ids": entity_ids}
143140

144-
result = self.client.post(f"/monitor/services/{service_type}/token", data=params)
141+
result = self.client.post(
142+
f"/monitor/services/{service_type}/token", data=params
143+
)
145144

146145
if "token" not in result:
147146
raise UnexpectedResponseError(
148147
"Unexpected response when creating token!", json=result
149148
)
150149
return CreateToken(self.client, result["token"], result)
151-
152-
153-
154-
155-
156-
157-
158-
159-
160-

linode_api4/objects/monitor.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ class Dashboard(Base):
1515
"type": Property(),
1616
"widgets": Property(mutable=True),
1717
"updated": Property(is_datetime=True),
18-
1918
}
2019

2120

22-
2321
class DashboardByService(Base):
2422
"""
2523
Get a dashboard: https://techdocs.akamai.com/linode-api/reference/get-dashboards
@@ -33,7 +31,6 @@ class DashboardByService(Base):
3331
"type": Property(),
3432
"widgets": Property(mutable=True),
3533
"updated": Property(is_datetime=True),
36-
3734
}
3835

3936

@@ -43,47 +40,43 @@ class MonitorServiceSupported(Base):
4340
id_attribute = "service_type"
4441
properties = {
4542
"service_type": Property(),
46-
"label": Property(mutable=True),
47-
43+
"label": Property(mutable=True),
4844
}
4945

46+
5047
class ServiceDetails(Base):
5148
"""
5249
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services-for-service-type
5350
"""
51+
5452
id_attribute = "service_type"
5553
properties = {
56-
"label": Property(),
57-
"service_type": Property(),
54+
"label": Property(),
55+
"service_type": Property(),
5856
}
5957

6058

61-
6259
class MetricDefinition(Base):
6360
"""
6461
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
6562
"""
6663

6764
id_attribute = "metric"
6865
properties = {
69-
"available_aggregate_functions": Property(),
70-
"dimensions": Property(mutable=True),
71-
"label": Property(),
66+
"available_aggregate_functions": Property(),
67+
"dimensions": Property(mutable=True),
68+
"label": Property(),
7269
"is_alertable": Property(),
7370
"metric": Property(),
7471
"metric_type": Property(),
7572
"scrape_interval": Property(),
7673
"unit": Property(),
7774
}
7875

76+
7977
class CreateToken(Base):
8078
"""
8179
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
8280
"""
8381

84-
properties = {
85-
"token": Property(mutable=True)
86-
}
87-
88-
89-
82+
properties = {"token": Property(mutable=True)}

test/integration/models/monitor/test_monitor.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,45 @@
2121
def test_get_all_dashboards(test_linode_client):
2222
client = test_linode_client
2323
dashboards = client.monitor.dashboards()
24-
assert isinstance(dashboards[0],Dashboard)
24+
assert isinstance(dashboards[0], Dashboard)
2525

2626
dashboard_get = dashboards[0]
2727
get_service_type = dashboard_get.service_type
2828

29-
#Fetch Dashboard by ID
29+
# Fetch Dashboard by ID
3030
dashboard_by_id = client.load(Dashboard, 1)
3131
assert isinstance(dashboard_by_id, Dashboard)
3232
assert dashboard_by_id.id == 1
3333

3434
# #Fetch Dashboard by service_type
35-
dashboards_by_svc = client.monitor.dashboards_by_service(service_type=get_service_type)
35+
dashboards_by_svc = client.monitor.dashboards_by_service(
36+
service_type=get_service_type
37+
)
3638
assert isinstance(dashboards_by_svc[0], DashboardByService)
3739
assert dashboards_by_svc[0].service_type == get_service_type
3840

39-
# List supported services
41+
42+
# List supported services
4043
def test_get_supported_services(test_linode_client):
4144
client = test_linode_client
4245
supported_services = client.monitor.supported_services()
4346
assert isinstance(supported_services[0], MonitorServiceSupported)
4447

4548
get_supported_service = supported_services[0].service_type
4649

47-
#Get details for a particular service
48-
service_details = client.monitor.details_by_service(service_type=get_supported_service)
49-
assert isinstance(service_details[0],ServiceDetails)
50+
# Get details for a particular service
51+
service_details = client.monitor.details_by_service(
52+
service_type=get_supported_service
53+
)
54+
assert isinstance(service_details[0], ServiceDetails)
5055
assert service_details[0].service_type == get_supported_service
5156

52-
#Get Metric definition details for that particular service
53-
metric_definitions = client.monitor.metric_definitions(service_type=get_supported_service)
54-
assert isinstance(metric_definitions[0],MetricDefinition)
57+
# Get Metric definition details for that particular service
58+
metric_definitions = client.monitor.metric_definitions(
59+
service_type=get_supported_service
60+
)
61+
assert isinstance(metric_definitions[0], MetricDefinition)
62+
5563

5664
# Test Helpers
5765
def get_db_engine_id(client: LinodeClient, engine: str):
@@ -63,6 +71,7 @@ def get_db_engine_id(client: LinodeClient, engine: str):
6371

6472
return str(engine_id)
6573

74+
6675
@pytest.fixture(scope="session")
6776
def test_create_and_test_db(test_linode_client):
6877
client = test_linode_client
@@ -71,7 +80,6 @@ def test_create_and_test_db(test_linode_client):
7180
engine_id = get_db_engine_id(client, "mysql")
7281
dbtype = "g6-standard-1"
7382

74-
7583
db = client.database.mysql_create(
7684
label=label,
7785
region=region,
@@ -89,27 +97,17 @@ def get_db_status():
8997
yield db
9098
send_request_when_resource_available(300, db.delete)
9199

100+
92101
def test_my_db_functionality(test_linode_client, test_create_and_test_db):
93102
client = test_linode_client
94103
assert test_create_and_test_db.status == "active"
95-
96-
entity_id = test_create_and_test_db.id
97104

105+
entity_id = test_create_and_test_db.id
98106

99107
# create token for the particular service
100-
token = client.monitor.create_token(service_type="dbaas", entity_ids=[entity_id])
108+
token = client.monitor.create_token(
109+
service_type="dbaas", entity_ids=[entity_id]
110+
)
101111
assert isinstance(token, CreateToken)
102112
assert len(token.token) > 0, "Token should not be empty"
103113
assert hasattr(token, "token"), "Response object has no 'token' attribute"
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-

0 commit comments

Comments
 (0)