Python SDK - JSON
Hi All, Apologies if this is a simple question, however I cannot find any documentation that can assist. My goal here is to have severity 3 alerts in a JSON file, however I am unable to convert this list ‘alerts’ to JSON and I cannot find any documentation in the SDK v3 that could address this. # create an instance of the API class api_instance = logicmonitor_sdk.LMApi(logicmonitor_sdk.ApiClient(configuration)) id = 138 # Integer | size = 1000 # Integer | (optional) offset = 0 # Integer | (optional) filter = f'severity:3,cleared:true,startEpoch>:{startEpoch},endEpoch<:{endEpoch}' # String | (optional) #Loop shiznit alerts = [] end_found = False while not end_found: current = api_instance.get_alert_list_by_device_group_id(id, size=size, offset=offset, filter=filter).items alerts += current offset += len(current) end_found = len(current) != size #Print and encode result to json. This allows you to use this variable later in an API Put. with open('./customer/json/cleared_sev3_alerts.json', 'w') as content_output_json: result_encoded = json.JSONEncoder(sort_keys=False, indent =4).encode(alerts) content_output_json.write(str(alerts)) content_output_json.close() print(len(alerts)) Whenever I try to encode this I get the following alert. TypeError: Object of type Alert is not JSON serializable Doing a jsonDump gives us the same output and I’ve scoured stackoverflow for a way to fix this, but no luck. Does anyone know how I can get around this? Thank you so muchSolved99Views3likes1CommentSDK install deprecated
Got this on a recent reinstall of logicmonitor_sdk using pip. DEPRECATION: logicmonitor_sdk is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 The part that worries me is that pip 23.1 will enforce the pyproject.toml and given the rate that LM publishes updates the SDK, pip installs will breakat some point. For me that point is pretty soon because 23.1 is the current version of pip. Luckily, I haven’t upgraded my pip from 22.3.1 to 23.1 like it’s prompting me to. Anybody else tried pip installing it while already on 23.1? Guess I’ll mock it up in docker.Solved87Views3likes4Commentsv3 Python SDK outdated?
Hello, I’m trying to use the Python SDK to add websites for monitoring. For my current use case, the primary reason for this is to gain some alerting on our SSL expiry times. Using the SDK has been a generally frustrating experience all around so far, however I’ve noticed that the v3 API is returning fields which aren’t supported or documented by the SDK or API docs. Specifically, for the Website endpoints (GET/POST/PUT), the top-level fields `schema`, `trigger_ssl_expiration_alert` and `trigger_ssl_status_alert` are all unsupported in the 3.0.172 SDK. Unfortunately these also all sound like the fields I need to be setting in order to get SSL monitoring set up. It also appears that the top-level `schema` field is required to enable HTTPS monitoring, as the `schema` field in the `steps` is ignored. I can see that this top-levle field is set to https when toggling the schema in the web UI, when using dev tools to inspect the request. I’ve already done a fair bit of work using the SDK, so I’d hate to have to rip it out at this point and start building all my requests manually in order to support this. I’m using logicmonitor_sdk 3.0.172 at present, which is the latest available release via Pip and tarball. I can see that these fields have been added on the master branch in Github. Is there a timeline for the release of these changes? While I’m here, can I also ask that this functionality is added to your Terraform provider, because that would save me a lot of hours and stress going forward. 😉75Views1like4CommentsPython SDK - modify a datasource
I am looking for a way to programmatically change a number of datasources. I searched through the API v3. documentation but couldn’t find any way. There are some calls to get information from datasources, but none to change them. I was expecting to find something like “patch_datasource_by_id”. Any ideas?Solved71Views5likes5Comments