def list(self, resource, **params): """Fetches a list of resources.""" res = self.resource_path.get(resource, None) if not res: raise oc_exc.OpenContrailAPINotSupported(action='list', resource=resource) self._resource = resource return self.get(res, params=params)
def create(self, resource, body): """Creates a new resource.""" res = self.resource_path.get(resource, None) if not res: raise oc_exc.OpenContrailAPINotSupported(action='create', resource=resource) self._resource = resource resp = self.post(res, body=body) if resp: return resp.popitem()[1]
def remove(self, resource, id): """Removes the specified resource.""" res = self.resource_path.get(resource, None) if not res: raise oc_exc.OpenContrailAPINotSupported(action='delete', resource=resource) if res[-2:] == 's/': res = res[:-2] + '/' self._resource = resource self._id = id return self.delete(res + id)
def update(self, resource, id, body=None): """Updates a resource.""" res = self.resource_path.get(resource, None) if not res: raise oc_exc.OpenContrailAPINotSupported(action='update', resource=resource) if res[-2:] == 's/': res = res[:-2] + '/' self._resource = resource self._id = id return self.put(res + id, body=body)
def show(self, resource, id, **params): """Fetches information of a certain resource.""" res = self.resource_path.get(resource, None) if not res: raise oc_exc.OpenContrailAPINotSupported(action='show', resource=resource) if res[-2:] == 's/': res = res[:-2] + '/' self._resource = resource self._id = id return self.get(res + id, params=params).popitem()[1]