Skip to content
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

Bcon/make query optional monitor update #192

Merged
Merged
10 changes: 7 additions & 3 deletions lib/dogapi/v1/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def monitor(type, query, options = {})
end

def update_monitor(monitor_id, query, options)
body = {
'query' => query,
}.merge options
body = {}.merge options
Copy link
Member

Choose a reason for hiding this comment

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

Rather than merging an empty hash, I would write it as :

      def update_monitor(monitor_id, query, options)
        unless query.nil?
          options['query'] = query
          warn '[DEPRECATION] query param is no longer required for update'
        end

        request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, options, true)
      end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason it's being picky about the order and local tests don't pass with this
¯_(ツ)_/¯

unless query.nil?
body = {
'query' => query
}.merge body
warn '[DEPRECATION] query param is no longer required for update'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not warn here. If someone does want to actually update the query, they should not see a deprecation message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually you were right to have this message. I misunderstood how all of it worked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok just put it back in with the updates!

end

request(Net::HTTP::Put, "/api/#{API_VERSION}/monitor/#{monitor_id}", nil, body, true)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dogapi/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dogapi
VERSION = '1.36.0'
VERSION = '1.36.1'
end