Skip to content

Commit

Permalink
Merge pull request #2 from jsenecal/develop
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
jsenecal authored Feb 27, 2023
2 parents 32db0bd + 3372a68 commit 9924365
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[tool.poetry]
name = "pyregrws"
version = "0.1.1"
version = "0.1.2"
description = "Python library to retrieve and modify records within ARIN's database through their Reg-RWS service"
authors = ["Jonathan Senecal <contact@jonathansenecal.com>"]
homepage = "https://github.com/jsenecal/pyregrws"
license = "Apache 2.0"
readme = "README.md"
classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion regrws/api/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _do(
from regrws.api.core import Session
from regrws.models import Error

with Session({200: return_type or self.model, 400: Error}) as session:
with Session({200: return_type or self.model, 400: Error, 404: Error}) as session:
session_method = getattr(session, verb)
res: Response = session_method(
url, params=self.url_params, data=data
Expand Down
3 changes: 3 additions & 0 deletions regrws/arin_xml_encoder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from typing import Any

from pydantic_xml.serializers import XmlEncoder
Expand All @@ -7,4 +8,6 @@ class ARINXmlEncoder(XmlEncoder):
def encode(self, obj: Any) -> str:
if isinstance(obj, bool):
return "true" if obj else "false"
if isinstance(obj, Enum):
return str(obj.value)
return super().encode(obj)
20 changes: 10 additions & 10 deletions regrws/models/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def remove(self, instance: type[Net]) -> TicketRequest | None:
)
return None # pragma: no cover

def reassign(self, instance: type[Net]) -> TicketRequest | None:
def reassign(self, instance: type[Net], net: type[Net]) -> TicketRequest | None:
"""This call performs a reassignment from the NET instance using the recipient information from the object."""
# Avoid circular import
from regrws.models.tickets import TicketRequest
Expand All @@ -61,14 +61,14 @@ def reassign(self, instance: type[Net]) -> TicketRequest | None:
return self._do(
"put",
url,
data=instance.to_xml(
data=net.to_xml(
encoder=ARINXmlEncoder(), encoding="UTF-8", skip_empty=True
), # type: ignore
return_type=TicketRequest,
)
return None # pragma: no cover

def reallocate(self, instance: type[Net]) -> TicketRequest | None:
def reallocate(self, instance: type[Net], net: type[Net]) -> TicketRequest | None:
"""This call performs a reallocation from the NET instance using the recipient information from the object."""
# Avoid circular import
from regrws.models.tickets import TicketRequest
Expand All @@ -79,7 +79,7 @@ def reallocate(self, instance: type[Net]) -> TicketRequest | None:
return self._do(
"put",
url,
data=instance.to_xml(
data=net.to_xml(
encoder=ARINXmlEncoder(), encoding="UTF-8", skip_empty=True
), # type: ignore
return_type=TicketRequest,
Expand Down Expand Up @@ -188,14 +188,14 @@ def remove(self) -> TicketRequest | None:
return None # pragma: no cover
return self._manager.remove(self)

def reassign(self, instance: type[Net]) -> TicketRequest | None:
"""Reassign the Net to a different Org or Customer"""
def reassign(self, net: type[Net]) -> TicketRequest | None:
"""Reassign the child Net to a different Org or Customer"""
if self._manager is None:
return None # pragma: no cover
return self._manager.reassign(instance)
return self._manager.reassign(self, net)

def reallocate(self, instance: type[Net]) -> TicketRequest | None:
"""Reallocate the Net to a different Org or Customer"""
def reallocate(self, net: type[Net]) -> TicketRequest | None:
"""Reallocate the child Net to a different Org or Customer"""
if self._manager is None:
return None # pragma: no cover
return self._manager.reallocate(instance)
return self._manager.reallocate(self, net)

0 comments on commit 9924365

Please sign in to comment.