b-loyola / itglue-py Goto Github PK
View Code? Open in Web Editor NEWA simple python wrapper for the IT Glue API
License: MIT License
A simple python wrapper for the IT Glue API
License: MIT License
Instead of causing an error when the API URL is not set, use the US endpoint https://api.itglue.com
by default.
I've been trying to lookup flexible assets via the API and receive a 422 error either direct via urllib or with this module:
>>> itglue.FlexibleAsset.get()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/itglue/resources.py", line 186, in get
data = cls._process_request(connection.get, parent=parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/itglue/resources.py", line 303, in _process_request
return request_func(path, **request_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/itglue/connection.py", line 34, in get
response = self._process_request(requests.get, url, params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/itglue/connection.py", line 80, in _process_request
raise self.ResponseError(response.status_code, response.text)
itglue.connection.Connection.ResponseError: (422, '{"errors":[{"status":422,"title":"Cannot index flexible assets without providing a flexible asset type ID filter","source":{"pointer":null}}]}')
Any idea what's missing?
How can we download documents & flexible assets using this lib?
Is there a special syntax for customers w/ commas or hyphens in their name? I get empty set for results.
Also, is there a syntax for wildcard matches? I looked at the API docs and the source code, but couldn't find a way to do it.
When trying to update a resource (e.g. configuration), adding keys like "configuration_status_id" it's being treated as a new attribute in the class since the return of the existing configuration has a key of "configuration-status-id". With python 3.0, the orders of the keys when adding to the dictionary is preserved, so it is updated with the new values, however with previous python versions (e.g. v 2.7), this is not the case.
We should update all the returned API results with underscores before returning the class.
E.g.
<Configuration id: 41080, attributes: {u’contact-id’: None, u’updated-at’: u'2018-08-23T00:21:57.000Z’, u’organization-name’: u’EC2 Test’, u’warranty-expires-at’: None, u’model-name’: None, u’serial-number’: u’i-00d5ef80d40ee2abd’, u’asset-tag’: None, ‘configuration_type_id’: u'6147', u’location-id’: 30530, ‘location_id’: u'30530', ‘configuration_status_id’: u'606', u’configuration-type-id’: 6147, u’purchased-by’: None, u’operating-system-notes’: None, u’restricted’: False, u’hostname’: None, u’installed-at’: None, u’adapter-sync-statuses’: None, u’default-gateway’: None, ‘mac_address’: ‘02:0e:ab:03:62:06’, ‘serial_number’: ‘i-00d5ef80d40ee2abd’, u’psa-integration’: None, u’mac-address’: u'02:0e:ab:03:62:06', u’manufacturer-name’: None, u’location-name’: u’us-west-2a’, ‘purchased_at’: ‘2018-08-23’, u’manufacturer-id’: None, u’organization-id’: 36656, u’operating-system-id’: None, u’model-id’: None, u’configuration-type-name’: u’EC2', u’operating-system-name’: None, u’my-glue’: False, u’contact-name’: None, u’name’: ‘testing’, u’configuration-status-name’: u’Active’, u’resource-url’: u’https://lisa.staging.itglue.com/36656/configurations/41080', u’primary-ip’: u'172.31.20.122', u’purchased-at’: u'2018-08-23', u’created-at’: u'2018-08-23T00:18:12.000Z’, u’installed-by’: None, u’configuration-status-id’: 283, u’position’: None, u’organization-short-name’: None, u’notes’: ‘private_dns_name: \tip-172-31-20-122.us-west-2.compute.internal\ninstance_type: \tt2.micro\nkey_name: \titg-dev-ec2-test\navailability_zone: \tus-west-2a\nimage_id: \tami-6cd6f714\npublic_dns_name: \t\nsecurity_groups: \tlaunch-wizard-4’}>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.