Hello,
Is there a way to set "hard_limit" for specific user using Rest API?
Actually I only need an example of get/post HTTP Request for setting/updating "hard_limit" for a user.
BR,
Pavel
Hi Pavel,
The answer seems to be no, not really. The hard_limit field is not tied to a single user, but rather to a rule. Each rule has a list of one or more users that it applies to.
If in your system, you create a new QuotaRule for every user, then you can achieve what you want with a single REST call by using the collection patch technique:
curl -iku admin -X PATCH -d '{"files": {"hard_limit": 100}}' https://<mgmt_ip>/api/storage/quota/rules?users.name=fred
A word of caution. This call will patch every quota rule that has the user fred listed in it. But if it's one to one, then that will do what you want. The quota team figured this was basically what the PowerShell Toolkit was doing behind the scenes since they didn't know of any API that was user based as the command would suggest.
This is the example from the API docs:
The following example shows how to update a quota policy rule. # The API: PATCH /storage/quota/rules/{uuid} # The call: curl -X PATCH "https://<mgmt-ip>/api/storage/quota/rules/364d38eb-8e87-11e8-a806-005056a7e73a" -H 'accept: application/hal+json' -d "@test_quota_patch.txt" test_quota_patch.txt(body): { "space": { "hard_limit": 16554, "soft_limit": 8192 }, "files": { "hard_limit": 40, "soft_limit": 20 } }
Or if you are using Python with the netapp-ontap library, the docs are here:
from netapp_ontap import HostConnection from netapp_ontap.resources import QuotaRule with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False): resource = QuotaRule(uuid="364d38eb-8e87-11e8-a806-005056a7e73a") resource.space.hard_limit = 16554 resource.space.soft_limit = 8192 resource.files.hard_limit = 40 resource.files.soft_limit = 20 resource.patch()
Hello RobertBlackhart,
First of all thank you for your reply once again.
Please correct me if I'm wrong, by changing rule I'm actually changing the rule, that applies not for specific user, but for multiple?
Yes, it would apply to all of the users in that rule's list. If you needed to have different limits for different users, I think you would need to have multiple quota rules.
If each user has his own quota, is it available to change user's for example "hard_limit"?
I'm asking, because in our company each user has his own quota and there is no rule, which is applied for all.
RobertBlackhart,
In our case I can get user's quota by following PowerShell command:
get-ncquotareport -target "someUser"
Each user has different "soft_limit" and "hard_limit".
Does it still mean there is different rule for each user?
I'm asking, because need to change from time to time "soft_limit" and "hard_limit" for different user.
In PowerShell I can do it based on user and not rule.
My question whether I can do it u based on user using Rest API as I do it with PowerShell?
Pavel p