openwisp / openwisp-ipam

IP address space administration module of OpenWISP
https://openwisp.io/docs/dev/ipam/
BSD 3-Clause "New" or "Revised" License
104 stars 51 forks source link

[api] Added Scoped Throttling #34 #81

Closed ManishShah120 closed 3 years ago

ManishShah120 commented 3 years ago

closses #34

ManishShah120 commented 3 years ago

@nemesisdesign, @atb00ker have a look :thinking:

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-0.01%) to 99.329% when pulling b9207f5a9a8bbd87dff0630c8507bae9c1c97175 on ManishShah120:issues/34-Add-scoped_throttling into b130a44537fd9bb50fd970bf6b497f8786da24b2 on openwisp:master.

ManishShah120 commented 3 years ago

@nemesisdesign , @atb00ker

ManishShah120 commented 3 years ago

@nemesisdesign I have done the changes as requested have a look.

ManishShah120 commented 3 years ago

I realized something important. We're not documenting how to change the default throttling settings. Can it be done without having to modify the code of openwisp-ipam? I mean just by adding something in settings.py. Can you double check this please and let me know?

Okay, @nemesisdesign I'll check and see if it can be done and let you know.

I think I'll have to open an issue for fw-upgrader too since it should be done there too.

Yeah, I guess so

ManishShah120 commented 3 years ago

I realized something important. We're not documenting how to change the default throttling settings. Can it be done without having to modify the code of openwisp-ipam? I mean just by adding something in settings.py. Can you double check this please and let me know? I think I'll have to open an issue for fw-upgrader too since it should be done there too.

Hey, @nemesisdesign I confirmed in other openwisp modules and found no sign of documentation related to changing of default throttling settings, So it will be a good idea to introduce in it.

And about the modification of the default throttling settings, yes it can be done but in that case, we will need to move this portion of the code from apps.py

REST_FRAMEWORK_SETTINGS = {
    'DEFAULT_THROTTLE_RATES': {
         'ipam': default_or_test('400/hour', None)},
}

to settings.py file, or if there is any other way possible please let me know. I'll try to learn and do it.

atb00ker commented 3 years ago

to settings.py file, or if there is any other way possible please let me know. I'll try to learn and do it.

This method looks good to me! :smile:

ManishShah120 commented 3 years ago

Yes, @nemesisdesign, It does override's the previous codes implemented in apps.py and takes effect whatever value is provided in the settings.py file and if we comment out this REST_FRAMEWORK from settings.py then again it takes effect whatever is implemented in apps.py file.

ManishShah120 commented 3 years ago

@nemesisdesign , Is this Okay.