From af849f6e1d29dbb8972466e4d8eb723b77c56e81 Mon Sep 17 00:00:00 2001 From: Shane Kerr Date: Tue, 19 Dec 2023 16:45:39 +0100 Subject: [PATCH] Format code using "black" formatter --- ns1/config.py | 3 +++ ns1/rest/account.py | 1 - ns1/rest/acls.py | 1 - ns1/rest/apikey.py | 1 - ns1/rest/client_classes.py | 1 - ns1/rest/data.py | 2 -- ns1/rest/monitoring.py | 4 ---- ns1/rest/pools.py | 1 - ns1/rest/records.py | 1 - ns1/rest/resource.py | 1 - ns1/rest/stats.py | 3 +-- ns1/rest/team.py | 1 - ns1/rest/transport/base.py | 1 - ns1/rest/user.py | 1 - ns1/rest/views.py | 1 - ns1/rest/zones.py | 32 +++++------------------------ ns1/zones.py | 2 -- tests/unit/test_zone.py | 41 ++++++++++++++++---------------------- 18 files changed, 26 insertions(+), 72 deletions(-) diff --git a/ns1/config.py b/ns1/config.py index 35cfa5d..2728b67 100644 --- a/ns1/config.py +++ b/ns1/config.py @@ -16,9 +16,12 @@ def decorator(func): def wrapper_func(): warnings.warn(reason, DeprecationWarning) func() + return wrapper_func + return deprecated + from ns1.rest.rate_limiting import default_rate_limit_func from ns1.rest.rate_limiting import rate_limit_strategy_concurrent from ns1.rest.rate_limiting import rate_limit_strategy_solo diff --git a/ns1/rest/account.py b/ns1/rest/account.py index 52fdece..4e87939 100644 --- a/ns1/rest/account.py +++ b/ns1/rest/account.py @@ -7,7 +7,6 @@ class Plan(resource.BaseResource): - ROOT = "account/plan" PASSTHRU_FIELDS = ["type", "period", "notes"] diff --git a/ns1/rest/acls.py b/ns1/rest/acls.py index 5dceefa..bbc69ca 100644 --- a/ns1/rest/acls.py +++ b/ns1/rest/acls.py @@ -7,7 +7,6 @@ class Acls(resource.BaseResource): - ROOT = "acls" PASSTHRU_FIELDS = ["src_prefixes", "tsig_keys", "gss_tsig_identities"] diff --git a/ns1/rest/apikey.py b/ns1/rest/apikey.py index 2e5915a..2a81e3b 100644 --- a/ns1/rest/apikey.py +++ b/ns1/rest/apikey.py @@ -8,7 +8,6 @@ class APIKey(resource.BaseResource): - ROOT = "account/apikeys" PASSTHRU_FIELDS = [ "name", diff --git a/ns1/rest/client_classes.py b/ns1/rest/client_classes.py index 92d0ca2..1bc7fda 100644 --- a/ns1/rest/client_classes.py +++ b/ns1/rest/client_classes.py @@ -7,7 +7,6 @@ class ClientClasses(resource.BaseResource): - ROOT = "dhcp" CLIENT_CLASS_ROOT = "clientclass" diff --git a/ns1/rest/data.py b/ns1/rest/data.py index 0b226e0..3bc5ab4 100644 --- a/ns1/rest/data.py +++ b/ns1/rest/data.py @@ -7,7 +7,6 @@ class Source(resource.BaseResource): - ROOT = "data/sources" PASSTHRU_FIELDS = ["name", "config"] @@ -76,7 +75,6 @@ def publish(self, sourceid, data, callback=None, errback=None): class Feed(resource.BaseResource): - ROOT = "data/feeds" PASSTHRU_FIELDS = ["name", "config"] diff --git a/ns1/rest/monitoring.py b/ns1/rest/monitoring.py index 54a6b53..b21e85a 100644 --- a/ns1/rest/monitoring.py +++ b/ns1/rest/monitoring.py @@ -7,7 +7,6 @@ class Monitors(resource.BaseResource): - ROOT = "monitoring/jobs" PASSTHRU_FIELDS = [ "name", @@ -69,7 +68,6 @@ def delete(self, jobid, callback=None, errback=None): class NotifyLists(resource.BaseResource): - ROOT = "lists" PASSTHRU_FIELDS = [] @@ -116,7 +114,6 @@ def delete(self, nlid, callback=None, errback=None): class JobTypes(resource.BaseResource): - ROOT = "monitoring/jobtypes" PASSTHRU_FIELDS = [] @@ -130,7 +127,6 @@ def list(self, callback=None, errback=None): class Regions(resource.BaseResource): - ROOT = "monitoring/regions" PASSTHRU_FIELDS = [] diff --git a/ns1/rest/pools.py b/ns1/rest/pools.py index 43d025b..f51c5ee 100644 --- a/ns1/rest/pools.py +++ b/ns1/rest/pools.py @@ -7,7 +7,6 @@ class Pools(resource.BaseResource): - ROOT = "ipam" ADDRESS_ROOT = "address" POOL_ROOT = "pool" diff --git a/ns1/rest/records.py b/ns1/rest/records.py index 0baf7fd..63e1d9b 100644 --- a/ns1/rest/records.py +++ b/ns1/rest/records.py @@ -15,7 +15,6 @@ class Records(resource.BaseResource): - ROOT = "zones" INT_FIELDS = ["ttl"] diff --git a/ns1/rest/resource.py b/ns1/rest/resource.py index c1ea037..66aa5e1 100644 --- a/ns1/rest/resource.py +++ b/ns1/rest/resource.py @@ -13,7 +13,6 @@ class BaseResource: - DEFAULT_TRANSPORT = "requests" INT_FIELDS = [] diff --git a/ns1/rest/stats.py b/ns1/rest/stats.py index c98c6a2..aa31b75 100644 --- a/ns1/rest/stats.py +++ b/ns1/rest/stats.py @@ -12,7 +12,6 @@ class Stats(resource.BaseResource): - ROOT = "stats" def qps( @@ -59,7 +58,7 @@ def usage( return self._make_request( "GET", - url + ('?' + urlencode(args) if args else ''), + url + ("?" + urlencode(args) if args else ""), callback=callback, errback=errback, pagination_handler=stats_usage_pagination, diff --git a/ns1/rest/team.py b/ns1/rest/team.py index e0d6829..066180a 100644 --- a/ns1/rest/team.py +++ b/ns1/rest/team.py @@ -8,7 +8,6 @@ class Team(resource.BaseResource): - ROOT = "account/teams" PASSTHRU_FIELDS = ["name", "ip_whitelist", "permissions"] diff --git a/ns1/rest/transport/base.py b/ns1/rest/transport/base.py index 0029c1b..85d4677 100644 --- a/ns1/rest/transport/base.py +++ b/ns1/rest/transport/base.py @@ -8,7 +8,6 @@ class TransportBase(object): - REGISTRY = {} def __init__(self, config, module): diff --git a/ns1/rest/user.py b/ns1/rest/user.py index 1938453..f1b1e1d 100644 --- a/ns1/rest/user.py +++ b/ns1/rest/user.py @@ -8,7 +8,6 @@ class User(resource.BaseResource): - ROOT = "account/users" PASSTHRU_FIELDS = [ "name", diff --git a/ns1/rest/views.py b/ns1/rest/views.py index 7981efa..60cbf5a 100644 --- a/ns1/rest/views.py +++ b/ns1/rest/views.py @@ -7,7 +7,6 @@ class Views(resource.BaseResource): - ROOT = "views" INT_FIELDS = [ "preference", diff --git a/ns1/rest/zones.py b/ns1/rest/zones.py index 98068b9..8d0d24c 100644 --- a/ns1/rest/zones.py +++ b/ns1/rest/zones.py @@ -110,12 +110,7 @@ def search( errback=errback, ) - def list_versions( - self, - zone, - callback=None, - errback=None - ): + def list_versions(self, zone, callback=None, errback=None): request = "{}/{}/versions".format(self.ROOT, zone) return self._make_request( "GET", @@ -125,12 +120,7 @@ def list_versions( errback=errback, ) - def create_version( - self, - zone, - force=False, - callback=None, - errback=None): + def create_version(self, zone, force=False, callback=None, errback=None): request = "{}/{}/versions?force={}".format( self.ROOT, zone, str.lower(str(force)) ) @@ -142,12 +132,7 @@ def create_version( errback=errback, ) - def activate_version( - self, - zone, - version_id, - callback=None, - errback=None): + def activate_version(self, zone, version_id, callback=None, errback=None): request = "{}/{}/versions/{}/activate".format( self.ROOT, zone, str(version_id) ) @@ -159,15 +144,8 @@ def activate_version( errback=errback, ) - def delete_version( - self, - zone, - version_id, - callback=None, - errback=None): - request = "{}/{}/versions/{}".format( - self.ROOT, zone, str(version_id) - ) + def delete_version(self, zone, version_id, callback=None, errback=None): + request = "{}/{}/versions/{}".format(self.ROOT, zone, str(version_id)) return self._make_request( "DELETE", request, diff --git a/ns1/zones.py b/ns1/zones.py index c4c45a6..7b3d4b2 100644 --- a/ns1/zones.py +++ b/ns1/zones.py @@ -123,7 +123,6 @@ def success(result, *args): ) def __getattr__(self, item): - if not item.startswith("add_"): raise AttributeError(item) @@ -160,7 +159,6 @@ def linkRecord( errback=None, **kwargs ): - """ Create a new linked record in this zone. These records use the configuration (answers, ttl, filters, etc) from an existing record diff --git a/tests/unit/test_zone.py b/tests/unit/test_zone.py index c2c67c9..f162c2a 100644 --- a/tests/unit/test_zone.py +++ b/tests/unit/test_zone.py @@ -52,59 +52,52 @@ def test_rest_zone_retrieve(zones_config, zone, url): ) -@pytest.mark.parametrize("zone, url", [("test.zone", "zones/test.zone/versions")]) +@pytest.mark.parametrize( + "zone, url", [("test.zone", "zones/test.zone/versions")] +) def test_rest_zone_version_list(zones_config, zone, url): z = ns1.rest.zones.Zones(zones_config) z._make_request = mock.MagicMock() z.list_versions(zone) z._make_request.assert_called_once_with( - "GET", - url, - params={}, - callback=None, - errback=None + "GET", url, params={}, callback=None, errback=None ) -@pytest.mark.parametrize("zone, url", [("test.zone", "zones/test.zone/versions?force=false")]) +@pytest.mark.parametrize( + "zone, url", [("test.zone", "zones/test.zone/versions?force=false")] +) def test_rest_zone_version_create(zones_config, zone, url): z = ns1.rest.zones.Zones(zones_config) z._make_request = mock.MagicMock() z.create_version(zone) z._make_request.assert_called_once_with( - "PUT", - url, - params={}, - callback=None, - errback=None + "PUT", url, params={}, callback=None, errback=None ) -@pytest.mark.parametrize("zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15/activate")]) +@pytest.mark.parametrize( + "zone, id, url", + [("test.zone", 15, "zones/test.zone/versions/15/activate")], +) def test_rest_zone_version_activate(zones_config, zone, id, url): z = ns1.rest.zones.Zones(zones_config) z._make_request = mock.MagicMock() z.activate_version(zone, id) z._make_request.assert_called_once_with( - "POST", - url, - params={}, - callback=None, - errback=None + "POST", url, params={}, callback=None, errback=None ) -@pytest.mark.parametrize("zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15")]) +@pytest.mark.parametrize( + "zone, id, url", [("test.zone", 15, "zones/test.zone/versions/15")] +) def test_rest_zone_version_delete(zones_config, zone, id, url): z = ns1.rest.zones.Zones(zones_config) z._make_request = mock.MagicMock() z.delete_version(zone, id) z._make_request.assert_called_once_with( - "DELETE", - url, - params={}, - callback=None, - errback=None + "DELETE", url, params={}, callback=None, errback=None )