Forum Discussion

chiel_boogaard's avatar
2 years ago

LM PY SDK error on swagger_client

Hi,

Im working on a script in python to add website checks. but the sdk documentation (https://www.logicmonitor.com/support-files/rest-api-developers-guide/sdks/docs/#api-LM-addWebsite) uses the following:

 

for instance in addWebsite:

 

```

body = swagger_client.models.Website(

```

it then gives me the following error: "swagger_client" is not defined

 

and i cannot find documentation on how to set this up.

 

Hope someone can help me.

3 Replies

  • You don't have to make it a swagger client. You can just make it a Python dictionary. I was able to add a website like this:

    body = {
        "testLocation":{"all":True},
        "name":"sdk_test",
        "type":"webcheck",
        "isInternal":False,
        "useDefaultAlertSetting":True,
        "useDefaultLocationSetting":True,
        "domain": "apple.com",
        "steps": [
            {
                'auth': None,
                'description': '',
                'enable': True,
                'follow_redirection': True,
                'fullpage_load': False,
                'http_body': '',
                'http_headers': '',
                'http_method': 'GET',
                'http_version': '1.1',
                'invert_match': False,
                'keyword': '',
                'label': '',
                'match_type': 'plain',
                'name': '__step0',
                'path': '',
                'post_data_edit_type': None,
                'req_script': '',
                'req_type': 'config',
                'require_auth': False,
                'resp_script': '',
                'resp_type': 'config',
                'schema': 'http',
                'status_code': '',
                'timeout': 30,
                'type': 'config',
                'url': '',
                'use_default_root': True
            }
        ]
    }
    lm.add_website(body)

     

  • Oh yeah, the examples assume your import statement looks like this:

    import logicmonitor_sdk as swagger_client