-
Notifications
You must be signed in to change notification settings - Fork 86
Monitor data source #92
base: master
Are you sure you want to change the base?
Monitor data source #92
Conversation
@louy could you please have a look at this PR? |
Any chance we could add tests for this? |
sure, on it |
2cc63cb
to
e8b0bb3
Compare
@louy it's ready for review now |
} | ||
|
||
func dataSourceMonitorRead(d *schema.ResourceData, m interface{}) error { | ||
monitors, err := m.(uptimerobotapi.UptimeRobotApiClient).GetMonitors() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the most efficient way to get a single monitor? Why not iterate over the list checking IDs only, and the build the Monitor object only for that single monitor we're interested in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Refactored to return monitor IDs that match the provided friendly_name
e8b0bb3
to
0a1d497
Compare
So I'm just wondering, would it make sense to use the |
Yeah, that would actually return few records to sift through |
@louy updated to use the |
@louy should be ready for review |
Compare page offset to total monitor records to know when to break from loop. This will avoid infinit loops in situations where a monitor gets added/removed mid-call.
Avoid constructing Monitor struct for each and every monitor record. Return IDs of monitor records that match the friendly name provided and build the Monitor object for the single monitor found.
Leverage the search parameter in getMonitors API so as to get filtered results instead of getting all monitors
c4fc6ef
to
131f2dc
Compare
Fixes #91