Skip to content

Upgrade to mreg-api 0.5.0 - #471

Merged
pederhan merged 5 commits into
masterfrom
mreg-api-0.5.0
Sep 1, 2026
Merged

Upgrade to mreg-api 0.5.0#471
pederhan merged 5 commits into
masterfrom
mreg-api-0.5.0

Conversation

@pederhan

@pederhan pederhan commented Aug 27, 2026

Copy link
Copy Markdown
Member

Yes... Another set of breaking changes in mreg-api that requires a new minor version.

Main changes:

  • No longer fetches created resource via Location header; 201 response provides created object.
  • No longer re-fetches object after PATCH request; new method refresh() provides this functionality if necessary (only used in host ttl_set).
  • CLI now responsible for raising exception when list() calls truncate results (len(results) > limit) via new strict_limit() context manager.

@pederhan
pederhan requested a review from terjekv August 31, 2026 15:08
@pederhan
pederhan marked this pull request as ready for review August 31, 2026 15:24
Comment thread mreg_cli/utilities/api.py Outdated
Comment on lines +47 to +63
@contextmanager
def strict_limit(client: MregClient) -> Generator[None, None, None]:
"""Context manager that aborts requests for a query that returns too many results.

Adds a temporary mreg-api handler that listens for TRUNCATE events and
raises TooManyResults if such an event is received.
"""

def fail_on_truncate(event: Event) -> None:
if event.kind == EventKind.TRUNCATION:
raise TooManyResults(f"{event.message} Refine your search.")

client.events.subscribe(fail_on_truncate)
try:
yield
finally:
client.events.unsubscribe(fail_on_truncate)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a general event listener we always have active instead of explicitly activated. Not sure what's best for this: implicit or explicit.

@terjekv terjekv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of having to remember the context manager, but LGTM.

@pederhan

pederhan commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

Not a huge fan of having to remember the context manager, but LGTM.

I will change it to an always-active rule. We only use limits in 2 places, so I don't think we'll accidentally trigger this exception if we enable it globally. I have another set of stashed changes ready, so I'll do it in that PR.

@pederhan
pederhan merged commit a03c0d0 into master Sep 1, 2026
18 checks passed
@pederhan
pederhan deleted the mreg-api-0.5.0 branch September 1, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants