-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for listing account activity #233
Merged
Merged
Conversation
This file contains 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
This adds a new service to enable listing NS1 account activity. The endpoint supports many url parameters to adjust response behavior (such as changing/limiting how many activity entries are returned, etc), but for this initial approach, the sdk just uses the endpoint directly with the endpoint's normal default values. I used a small Terraform config to generate 50 dummy DNS records on my NS1 account to generate some account activity and have confirmed that the endpoint operates as expected -- the values I expected are returned, the response is limited to the last 20 activity entries like the endpoint default, etc. Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
tjhop
force-pushed
the
feat/account-activity-support
branch
from
April 4, 2024 14:20
de40e55
to
5ed1f9e
Compare
Zach-Johnson
reviewed
Apr 4, 2024
tjhop
added a commit
to tjhop/ns1-go
that referenced
this pull request
Apr 4, 2024
Several NS1 API endpoints allow setting URL parameters to alter the behavior of the endpoint. For instance, a `limit` parameter can be set on the `/account/activity` endpoint to control how many events are returned in the response. This would be useful in ns1#233. This commit adds support for URL parameters by adding a new struct `Param` to the `rest` package, and updating `rest.client.Do()` and `rest.client.DoWithPagination()` to accept a variable amount of params. In order for higher level services based off of the common service to set url params, they will need to pass them through when invoking the client's `Do()` method, like so: ```golang resp, err := s.client.Do(req, &al, params...) ```
tjhop
force-pushed
the
feat/account-activity-support
branch
from
April 4, 2024 19:24
44b1617
to
3f841e0
Compare
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Zach-Johnson
approved these changes
Apr 4, 2024
tjhop
added a commit
to tjhop/ns1_exporter
that referenced
this pull request
Apr 25, 2024
I added support to ns1-go to list account activity upstream: ns1/ns1-go#233 This adds support for utilizing this endpoint for more efficient service discovery updates. It uses a similar refresh mechanism to what I used when working on linode service discovery for prometheus: https://github.com/prometheus/prometheus/blob/76b0318ed52e655e96a3a4734e3678bf55801616/discovery/linode/linode.go#L183-L231 Rather than refreshing all zone/record cache on every refresh interval, the SD mechanism will now poll the `/account/activity` endpoint. If activity is detected that could affect the zone/record data used to create SD targets, then the SD mechanism will actually go ahead and refresh it's cache. There's a max of 10 polls with no activity detected before refreshing cache regardless of activity status, to ensure that cache is valid/recent.
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.
This adds a new service to enable listing NS1 account activity. The endpoint supports many url parameters to adjust response behavior (such as changing/limiting how many activity entries are returned, etc), but for this initial approach, the sdk just uses the endpoint directly with the endpoint's normal default values.
I used a small Terraform config to generate 50 dummy DNS records on my NS1 account to generate some account activity and have confirmed that the endpoint operates as expected -- the values I expected are returned, the response is limited to the last 20 activity entries like the endpoint default, etc.