HPLeftHand HTTP Client
Author: | Walter A. Boring IV |
---|---|
Description: | This is the HTTP Client that is used to make the actual calls. It includes the authentication that knows the cookie name for LH. |
An HTTP REST Client that sends and recieves JSON data as the body of the HTTP request.
Parameters: |
|
---|
This tries to create an authenticated session with the LH OS server
Parameters: |
|
---|
This turns on/off http request/response debugging output to console
Parameters: | flag (bool) – Set to True to enable debugging output |
---|
This makes an HTTP Request to the LH server. You should use get, post, delete instead.
Make an HTTP GET request to the server.
#example call
try {
headers, body = http.get('/volumes')
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP POST request to the server.
#example call
try {
info = {'name': 'new volume name', 'sizeMiB': 300}
headers, body = http.post('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP PUT request to the server.
#example call
try {
info = {'name': 'something'}
headers, body = http.put('/volumes', body=info)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object
Make an HTTP DELETE request to the server.
#example call
try {
headers, body = http.delete('/volumes/%s' % name)
} except exceptions.HTTPUnauthorized as ex:
print "Not logged in"
}
Parameters: | url (str) – The relative url from the LH api_url |
---|---|
Returns: | headers - dict of HTTP Response headers |
Returns: | body - the body of the response. If the body was JSON, |
it will be an object