@@ -855,23 +855,74 @@ def receive_random_data(self, generator_id: int):
855
855
path = self ._compose_path ("integrations/words/{0}" .format (generator_id ))
856
856
return self ._get (path )
857
857
858
- def receive_user_info (self ):
858
+ def get_user_info (self ):
859
859
"""
860
860
Get detailed account information for the current user.
861
861
862
862
See https://io.adafruit.com/api/docs/#get-user-info
863
863
"""
864
864
return self ._get ("https://io.adafruit.com/api/v2/user" )
865
865
866
- def receive_user_rate_info (self ):
866
+ def get_user_rate_info (self ):
867
867
"""
868
868
Get rate limit and usage information for the current user.
869
869
870
870
See https://io.adafruit.com/api/docs/#get-detailed-user-info
871
+
872
+ Exampple output:
873
+ ```
874
+ {
875
+ "data_rate_limit": 30,
876
+ "active_data_rate": 0,
877
+ "authentication_rate": 0,
878
+ "subscribe_authorization_rate": 0,
879
+ "publish_authorization_rate": 0,
880
+ "hourly_ban_rate": 0,
881
+ "mqtt_ban_error_message": null,
882
+ "active_sms_rate": 0
883
+ }
884
+ ```
871
885
"""
872
886
path = self ._compose_path ("throttle" )
873
887
return self ._get (path )
874
888
889
+ def get_remaining_throttle_limit (self ):
890
+ """
891
+ Get the remaining data points allowed before hitting the throttle limit.
892
+ This retrieves the user rate limit and deducts usage for the current user.
893
+
894
+ See https://io.adafruit.com/api/docs/#get-detailed-user-info
895
+ """
896
+ path = self ._compose_path ("throttle" )
897
+ user_rates = self ._get (path )
898
+ if user_rates is None :
899
+ raise Exception ("Could not get user info, get_user_rate_info returned None." )
900
+ return user_rates ["data_rate_limit" ] - user_rates ["active_data_rate" ]
901
+
902
+ def get_throttle_limit (self ):
903
+ """
904
+ Get user throttle limit a.k.a "data_rate_limit" for the current user.
905
+
906
+ See https://io.adafruit.com/api/docs/#get-detailed-user-info
907
+ """
908
+ path = self ._compose_path ("throttle" )
909
+ user_rates = self ._get (path )
910
+ if user_rates is None :
911
+ raise Exception ("Could not get user info, get_user_rate_info returned None." )
912
+ return user_rates ["data_rate_limit" ]
913
+
914
+ def get_current_usage (self ):
915
+ """
916
+ Get current rate usage a.k.a "active_data_rate" for the current user.
917
+
918
+ See https://io.adafruit.com/api/docs/#get-detailed-user-info
919
+ """
920
+ path = self ._compose_path ("throttle" )
921
+ user_rates = self ._get (path )
922
+ if user_rates is None :
923
+ raise Exception ("Could not get user info, get_user_rate_info returned None." )
924
+ return user_rates ["active_data_rate" ]
925
+
875
926
def receive_time (self , timezone : str = None ):
876
927
"""
877
928
Returns a struct_time from the Adafruit IO Server based on the device's IP address.
0 commit comments