czwartek, 19 maja 2016

Lenovo XClarity Authentication REST API

XClarity is virtual appliance (both for Vmware and MS Hyper-V) for convenient managing Lenovo servers.Check this out.

It provides three methods for accessing and managing it:
- WebUI
- PowerShell Cmdlets

We've already discovered some features by web ui and at this moment we are interested in API.
You can take a look on reference here. There's no information about authentication method but it's simple!

Just type:
curl -XGET https://{xclarity_host}/{endpoint} -H ""Authorization: Basic {base64 encoded user:pass }"

curl -XGET -H "Authorization: Basic Zm9vOmJhcgo="

add "-v" to see headers and "--insecure" to access fresh installed XClarity (because it's self signed certificate)

niedziela, 13 września 2015

Django REST Framework - permission_classes - 'type' object is not iterable

I was developing medium project for university using django and djangorestframework and some kind of strange problem occured when using function based views for API views:
TypeError at /api-test/custom/users/ 'type' object is not iterable
googling, stackoverflow'ing for solutions: but it doesn't help. Solution was simple. Instead of:
def user_list(request): # output ommited
I have to use square brackets (python list):
@permission_classes([permissions.IsAdminUser, ])
def user_list(request): # output ommited
And it works!