Skip to content

Commit 083db2f

Browse files
fix linting
1 parent 8f1e8da commit 083db2f

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
lines changed

examples/usage_alerts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
# If no real API key is set, we'll get appropriate errors
2929
# This is just an example to show the usage pattern
3030
if not os.environ.get("NS1_APIKEY"):
31-
print("Using a mock endpoint - for real usage, set the NS1_APIKEY environment variable")
31+
print(
32+
"Using a mock endpoint - for real usage, set the NS1_APIKEY environment variable"
33+
)
3234

3335

3436
# Usage Alerts API Examples

ns1/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ def alerts(self):
242242

243243
return ns1.rest.alerts.Alerts(self.config)
244244

245-
246245
def billing_usage(self):
247246
"""
248247
Return a new raw REST interface to BillingUsage resources

ns1/alerting/usage_alerts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def _validate(name: str, subtype: str, alert_at_percent: int) -> None:
2424
class UsageAlertsAPI:
2525
"""
2626
Account-scoped usage alerts. Triggers when usage ≥ alert_at_percent.
27-
28-
Server rules:
29-
- Always type='account'
27+
28+
Server rules:
29+
- Always type='account'
3030
- data.alert_at_percent must be in 1..100
3131
- PATCH must not include type/subtype
3232
- zone_names/notifier_list_ids may be empty ([])

ns1/rest/alerts.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,53 @@ class Alerts(resource.BaseResource):
1616
"record_ids",
1717
"zone_names",
1818
]
19-
19+
2020
# Forward HTTP methods needed by UsageAlertsAPI
2121
def _get(self, path, params=None):
2222
"""Forward GET requests to make_request"""
2323
# Fix path to start with /alerting/v1/ if needed
24-
if path.startswith('/'):
24+
if path.startswith("/"):
2525
path = path[1:] # Remove leading slash
2626
if not path.startswith("alerting/v1/"):
2727
# Alerting endpoints should have this prefix
2828
path = f"{self.ROOT}/{path.split('/')[-1]}"
2929
return self._make_request("GET", path, params=params)
30-
30+
3131
def _post(self, path, json=None):
3232
"""Forward POST requests to make_request"""
33-
if path.startswith('/'):
33+
if path.startswith("/"):
3434
path = path[1:] # Remove leading slash
3535
if not path.startswith("alerting/v1/"):
3636
path = f"{self.ROOT}"
3737
return self._make_request("POST", path, body=json)
38-
38+
3939
def _patch(self, path, json=None):
4040
"""Forward PATCH requests to make_request"""
41-
if path.startswith('/'):
41+
if path.startswith("/"):
4242
path = path[1:] # Remove leading slash
4343
if not path.startswith("alerting/v1/"):
44-
parts = path.split('/')
44+
parts = path.split("/")
4545
path = f"{self.ROOT}/{parts[-1]}"
4646
return self._make_request("PATCH", path, body=json)
47-
47+
4848
def _delete(self, path):
4949
"""Forward DELETE requests to make_request"""
50-
if path.startswith('/'):
50+
if path.startswith("/"):
5151
path = path[1:] # Remove leading slash
5252
if not path.startswith("alerting/v1/"):
53-
parts = path.split('/')
53+
parts = path.split("/")
5454
path = f"{self.ROOT}/{parts[-1]}"
5555
return self._make_request("DELETE", path)
56-
56+
5757
def __init__(self, config):
5858
super(Alerts, self).__init__(config)
5959
self._usage_api = None
60-
60+
6161
@property
6262
def usage(self):
6363
"""
6464
Return interface to usage alerts operations
65-
65+
6666
:return: :py:class:`ns1.alerting.UsageAlertsAPI`
6767
"""
6868
if self._usage_api is None:

tests/unit/test_datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def datasets_config(config):
2828
return config
2929

3030

31-
@pytest.mark.parametrize("url", [("datasets")])
31+
@pytest.mark.parametrize("url", ["datasets"])
3232
def test_rest_datasets_list(datasets_config, url):
3333
z = NS1(config=datasets_config).datasets()
3434
z._make_request = mock.MagicMock()
@@ -62,7 +62,7 @@ def test_rest_dataset_retrieve(datasets_config, dtId, url):
6262
)
6363

6464

65-
@pytest.mark.parametrize("url", [("datasets")])
65+
@pytest.mark.parametrize("url", ["datasets"])
6666
def test_rest_dataset_create(datasets_config, url):
6767
z = NS1(config=datasets_config).datasets()
6868
z._make_request = mock.MagicMock()

tests/unit/test_usage_alerts.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ def test_create_usage_alert(usage_alerts_client):
5252
# Get the usage API and directly set its client
5353
usage_api = client.alerts().usage
5454
usage_api._c = client
55-
55+
5656
# Make the API call
5757
alert = usage_api.create(
58-
name="Test Alert",
59-
subtype="query_usage",
60-
alert_at_percent=85,
61-
notifier_list_ids=["n1"],
62-
)
58+
name="Test Alert",
59+
subtype="query_usage",
60+
alert_at_percent=85,
61+
notifier_list_ids=["n1"],
62+
)
6363

6464
# Verify _post was called with correct arguments
6565
expected_body = {
@@ -102,7 +102,7 @@ def test_get_usage_alert(usage_alerts_client):
102102
# Get the usage API and directly set its client
103103
usage_api = client.alerts().usage
104104
usage_api._c = client
105-
105+
106106
# Make the API call
107107
alert = usage_api.get(alert_id)
108108

@@ -135,7 +135,7 @@ def test_patch_usage_alert(usage_alerts_client):
135135
# Get the usage API and directly set its client
136136
usage_api = client.alerts().usage
137137
usage_api._c = client
138-
138+
139139
# Make the API call
140140
alert = usage_api.patch(
141141
alert_id, name="Updated Alert", alert_at_percent=90
@@ -169,7 +169,7 @@ def test_delete_usage_alert(usage_alerts_client):
169169
# Get the usage API and directly set its client
170170
usage_api = client.alerts().usage
171171
usage_api._c = client
172-
172+
173173
# Make the API call
174174
usage_api.delete(alert_id)
175175

@@ -201,7 +201,7 @@ def test_list_usage_alerts(usage_alerts_client):
201201
# Get the usage API and directly set its client
202202
usage_api = client.alerts().usage
203203
usage_api._c = client
204-
204+
205205
# Make the API call
206206
response = usage_api.list(limit=1, order_descending=True)
207207

0 commit comments

Comments
 (0)