Package cm_api :: Module resource :: Class Resource
[hide private]
[frames] | no frames]

Class Resource

source code

object --+
         |
        Resource
Known Subclasses:

Encapsulates a resource, and provides actions to invoke on it.

Instance Methods [hide private]
 
__init__(self, client, relpath='')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_join_uri(self, relpath) source code
 
invoke(self, method, relpath=None, params=None, data=None, headers=None)
Invoke an API method.
source code
 
get(self, relpath=None, params=None)
Invoke the GET method on a resource.
source code
 
delete(self, relpath=None, params=None)
Invoke the DELETE method on a resource.
source code
 
post(self, relpath=None, params=None, data=None, contenttype=None)
Invoke the POST method on a resource.
source code
 
put(self, relpath=None, params=None, data=None, contenttype=None)
Invoke the PUT method on a resource.
source code
 
_make_headers(self, contenttype=None) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  base_url

Inherited from object: __class__

Method Details [hide private]

__init__(self, client, relpath='')
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • client - A Client object.
  • relpath - The relative path of the resource.
Overrides: object.__init__

invoke(self, method, relpath=None, params=None, data=None, headers=None)

source code 

Invoke an API method.

Returns:
Raw body or JSON dictionary (if response content type is JSON).

get(self, relpath=None, params=None)

source code 

Invoke the GET method on a resource.

Parameters:
  • relpath - Optional. A relative path to this resource's path.
  • params - Key-value data.
Returns:
A dictionary of the JSON result.

delete(self, relpath=None, params=None)

source code 

Invoke the DELETE method on a resource.

Parameters:
  • relpath - Optional. A relative path to this resource's path.
  • params - Key-value data.
Returns:
A dictionary of the JSON result.

post(self, relpath=None, params=None, data=None, contenttype=None)

source code 

Invoke the POST method on a resource.

Parameters:
  • relpath - Optional. A relative path to this resource's path.
  • params - Key-value data.
  • data - Optional. Body of the request.
  • contenttype - Optional.
Returns:
A dictionary of the JSON result.

put(self, relpath=None, params=None, data=None, contenttype=None)

source code 

Invoke the PUT method on a resource.

Parameters:
  • relpath - Optional. A relative path to this resource's path.
  • params - Key-value data.
  • data - Optional. Body of the request.
  • contenttype - Optional.
Returns:
A dictionary of the JSON result.

Property Details [hide private]

base_url

Get Method:
unreachable.base_url(self)