This repository has been archived by the owner on Feb 16, 2022. It is now read-only.
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.
Proposed Changes
This PR adds support for the two Anomaly endpoints:
GET /api/v2/anomaly/blocks/ips/{id}
: https://auth0.com/docs/api/management/v2#!/Anomaly/get_ips_by_idDELETE /api/v2/anomaly/blocks/ips/{id}
: https://auth0.com/docs/api/management/v2#!/Anomaly/delete_ips_by_idThe GET endpoint, unlike the other API2 endpoints, takes no data in the request body and returns no data in the response body (except in the case of error). The only input is an IP address passed as part of the path, and the outcome of the operation is signaled by status codes.
A status code of
200
means that the IP is blocked, and a status code of404
means that it is not blocked.The current request-making logic does not expose the status code, and returning the error does not make sense as a
404
will end up as an error, when it's a non-error output. So instead of callingm.Request
directly, the implementation ofCheckIP
adapts the code ofm.Request
to work around these peculiarities.The DELETE endpoint does not return data in the response body either (except in the case of error), but it does not use an error status code for a non-error output. So
UnblockIP
just callsm.Request
directly.Acceptance Test Output
This was tested manually by calling a command on a modified Auth0 CLI.
Community Note