feat: add create_domain(), and fix a slash-only fqdn - #7
Merged
Conversation
Domain.from_api_response() validated the raw fqdn and stripped the
trailing slashes afterwards, so a payload such as {"fqdn": "/"} passed
validation and produced Domain(domain=""). Validate the stripped value
instead, and raise the same InvalidResponseError as a missing field so
the caller has one case to handle.
Reported by a user who read model="Domain" as a schema mapping; it is
only the label used in error messages, and reading "fqdn" from the raw
payload is correct.
PUT /v2/organisations/{ownerId}/applications/{appId}/vhosts/{domain}.
The SDK could list domains and read the primary one, but not attach a
new one.
The name is stripped of its trailing slash before being percent-encoded,
so it round-trips with Domain.domain and a path suffix such as
"example.com/api" stays part of the vhost name instead of changing which
endpoint the request reaches. Some deployments answer with an empty
body, so the returned Domain falls back to the requested name.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related changes on domains, from a user report.
fix: a slash-onlyfqdnproduced an empty domainDomain.from_api_response()validated the rawfqdnand stripped the trailing slashes afterwards, so{"fqdn": "/"}passed validation and producedDomain(domain=""). The stripped value is now what gets validated, and it raises the sameInvalidResponseErroras a missing field — one case for the caller to handle, not two.The report also flagged
_require_str(data, "fqdn", model="Domain")as reading the wrong key, on the reading that_mapping(data, model="Domain")maps the payload onto the dataclass. It does not:model=is only the label used to build the error message,_mapping()returns the payload unchanged, and"fqdn"is the key the API actually sends. No change needed there.feat:create_domain()PUT /v2/organisations/{ownerId}/applications/{appId}/vhosts/{domain}. The SDK could list domains and read the primary one, but not attach a new one.Domain.domainand a path suffix such asexample.com/apistays part of the vhost name instead of changing which endpoint the request reaches.PUTwith an empty body; the returnedDomainthen falls back to the requested name.Named
create_domainfor consistency withcreate_application/create_tcp_redirection.Tests
Four cases for
create_domain(nominal, empty body, encoded path suffix, empty name rejected) and one parametrized case for the slash-onlyfqdn. Full suite,ruff checkandmypyall pass.CHANGELOG.mdis untouched on purpose: perRELEASING.md, the section is written when the version is cut.