Skip to content

Commit

Permalink
Support 202405 (#90)
Browse files Browse the repository at this point in the history
* Support 202405

Client.update_all() method to update all objects in the database - this existed in v1 and has now been readded

* linting

---------

Co-authored-by: 20C <[email protected]>
  • Loading branch information
vegu and 20c-ed authored Jun 20, 2024
1 parent aa00fd7 commit ba9add6
Show file tree
Hide file tree
Showing 11 changed files with 643 additions and 661 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


## Unreleased
### Added
- Client.update_all() method to update all objects in the database - this existed in v1 and has now been readded
### Fixed
- fixes automatic solving of unique constraint errors (#85)

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Unreleased:
added: []
added:
- Client.update_all() method to update all objects in the database - this existed in v1 and has now been readded
fixed:
- fixes automatic solving of unique constraint errors (#85)
changed: []
Expand Down
1,273 changes: 620 additions & 653 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/peeringdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
PeeringDB API
"""

import logging
import sys
from importlib import import_module
Expand Down
1 change: 1 addition & 0 deletions src/peeringdb/_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Sync implementation module
"""

from collections import defaultdict

from peeringdb.util import group_fields
Expand Down
2 changes: 1 addition & 1 deletion src/peeringdb/_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module defining main interface classes for sync
"""

import logging
from datetime import datetime
from typing import List, Union
Expand All @@ -13,7 +14,6 @@


class Updater:

"""
Handles initial and incremental update from a PeeringDB remote API
to the local backend.
Expand Down
3 changes: 0 additions & 3 deletions src/peeringdb/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, name):


class EmptyContext:

"""
We use this to provide a dummy context wherever it's optional
"""
Expand All @@ -54,7 +53,6 @@ def __exit__(self, *args):


class Base:

"""
Backend base class.
Expand Down Expand Up @@ -105,7 +103,6 @@ def get_resource(self, cls):


class Interface(Base):

"""
backend adapter interface
Expand Down
4 changes: 4 additions & 0 deletions src/peeringdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def all(self, res):
backend = get_backend()
return backend.get_objects(backend.get_concrete(res))

def update_all(self):
"""Update all resources from the API."""
return self.updater.update_all(resource.all_resources())

@property
def backend(self):
return get_backend()
9 changes: 6 additions & 3 deletions src/peeringdb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This defines config schemas and related I/O.
"""

import os

import munge
Expand Down Expand Up @@ -47,9 +48,11 @@ class SyncSchema(_schema.Schema):
only = _schema.List(
"only",
item=_schema.Str(),
default=os.environ.get("PDB_SYNC_ONLY", "").split(",")
if os.environ.get("PDB_SYNC_ONLY")
else [],
default=(
os.environ.get("PDB_SYNC_ONLY", "").split(",")
if os.environ.get("PDB_SYNC_ONLY")
else []
),
)
timeout = _schema.Int(
"timeout", default=int(os.environ.get("PDB_SYNC_TIMEOUT", "0"))
Expand Down
1 change: 1 addition & 0 deletions src/peeringdb/resource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
PeeringDB resource definitions
"""

from collections import OrderedDict

# Generate classes
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_get(client):
client.get(resource.Network, 9999)


def test_update_all(client):
client.update_all()
assert client.get(resource.Network, NET0)


def test_type_wrap(client):
assert client.tags.net.get(NET0)
assert client.tags.net.all()

0 comments on commit ba9add6

Please sign in to comment.