Example #1
0
    def update(self, request, id):
        """PUT request.  Update resource pool.

        Please see the documentation for the 'create' operation for detailed
        descriptions of each parameter.

        Optional parameters
        -------------------

        name
            Name of the resource pool.

        description
            Description of the resource pool.

        Returns 404 if the resource pool is not found.
        """

        pool = ResourcePool.objects.get_resource_pool_or_404(
            id, request.user, NODE_PERMISSION.ADMIN)
        form = ResourcePoolForm(instance=pool, data=request.data)
        if form.is_valid():
            return form.save()
        else:
            raise MAASAPIValidationError(form.errors)
Example #2
0
    def update(self, request, id):
        """@description Updates a resource pool's name or description.

        Note that any other given parameters are silently ignored.

        @param (url-string) "{id}" [required=true] The resource pool id/name to
            update.
        @param (string) "description" [required=false] A brief description of
            the resource pool.
        @param (string) "name" [required=false] The resource pool's new name.
        @param-example "{id}" myresourcepool
        @param-example "name" newname
        @param-example "description" An updated resource pool
            description.

        @success (http-status-code) "serversuccess" 200
        @success (content) "contentsuccess" A JSON object containing details
            about your new resource pool.
        @success-example "contentsuccess"
            {
                "name": "test-update-renamed",
                "description": "This is a new resource pool for updating.",
                "id": 80,
                "resource_uri": "/MAAS/api/2.0/resourcepool/80/"
            }

        @error (http-status-code) "404" 404
        @error (content) "notfound" Zone not found
        @error-example "notfound"
            Not Found
        """

        pool = ResourcePool.objects.get_resource_pool_or_404(
            id, request.user, NODE_PERMISSION.ADMIN)
        form = ResourcePoolForm(instance=pool, data=request.data)
        if form.is_valid():
            return form.save()
        else:
            raise MAASAPIValidationError(form.errors)