コード例 #1
0
    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)
コード例 #2
0
    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]
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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]