brennerm / check-mk-web-api

Python library to talk to the Check_Mk Web API
https://brennerm.github.io/check-mk-web-api/
MIT License
53 stars 26 forks source link

How to specify refresh type? #3

Closed jake9050 closed 7 years ago

jake9050 commented 7 years ago

Hi,

First of all thanks for this api wrapper!

I see that you define this:

    class DiscoverMode(enum.Enum):
        """
        new - Only discover new services
        remove - Remove exceeding services
        fixall - Remove exceeding services and discover new services
        refresh - Start from scratch
        """
        NEW = 'new'
        REMOVE = 'remove'
        FIXALL = 'fixall'
        REFRESH = 'refresh'

And then you set the discovery request to NEW:

discover_services(self, hostname: str, mode: DiscoverMode=DiscoverMode.NEW):

Can this be overridden to the other types? I have tried various ways of doing this:

api.discover_services(host,  DiscoverMode='REFRESH')
'str' object has no attribute 'value'
api.discover_services(h, 'mode:REFRESH')
'str' object has no attribute 'value'
api.discover_services(h, mode.REFRESH)
name 'mode' is not defined
api.discover_services(h, DiscoverMode.REFRESH)
name 'DiscoverMode' is not defined

I am not very proficient in python yet, but if you could give me some pointers i should be able to figure out what to change.

brennerm commented 7 years ago

Hey @jake9050,

make sure to have the WebApi class imported from the _check_mk_webapi module.

from check_mk_web_api import WebApi

Afterwards you have access to the DiscoverMode enum.

api.discover_services(h, WebApi.DiscoverMode.FIXALL)
jake9050 commented 7 years ago

Thanks for the swift response @brennerm , now i can make it do what i want.