1
+ from typing import List
2
+
3
+
4
+ class MetricsApiConfig :
5
+ """
6
+ ReadMe Metrics API configuration object
7
+
8
+ ...
9
+ Attributes
10
+ ----------
11
+ README_API_KEY: str
12
+ (required) Your ReadMe API key
13
+ GROUPING_FUNCTION = lambda
14
+ (required)
15
+ Grouping function to construct an identity object. It receives the current request as a parameter, and must
16
+ return a dictionary containing at least an "id" field, and optionally "label" and "email" fields.
17
+
18
+ The main purpose of the identity object is to identify the API's caller.
19
+ BUFFER_LENGTH: int
20
+ (optional, default = 10)
21
+ Number of requests to buffer before sending data to ReadMe.
22
+ IS_DEVELOPMENT_MODE: bool
23
+ (optional, default = False) Determines whether you are running in development mode.
24
+ IS_BACKGROUND_MODE: bool
25
+ (optional, default = True) Determines whether to issue the call to the ReadMe API in a background thread.
26
+ BLACKLIST: List[str]
27
+ (optional) An array of headers and JSON body properties to skip sending to ReadMe.
28
+
29
+ If you configure a blacklist, it will override any whitelist configuration.
30
+ WHITELIST: List[str]
31
+ (optional) An array of headers and JSON body properties to send to ReadMe.
32
+
33
+ If this option is configured, ONLY the whitelisted properties will be sent.
34
+ """
35
+ README_API_KEY : str = None
36
+ BUFFER_LENGTH : int = 10
37
+ GROUPING_FUNCTION = lambda req : None
38
+ IS_DEVELOPMENT_MODE : bool = False
39
+ IS_BACKGROUND_MODE : bool = True
40
+ BLACKLIST : List [str ] = []
41
+ WHITELIST : List [str ] = []
42
+
43
+ def __init__ (self ,
44
+ api_key : str ,
45
+ grouping_function ,
46
+ buffer_length :int = 10 ,
47
+ development_mode :bool = False ,
48
+ background_worker_mode :bool = True ,
49
+ blacklist :List [str ] = None ,
50
+ whitelist :List [str ] = None ):
51
+ """
52
+ Initializes an instance of the MetricsApiConfig object, with defaults set where possible.
53
+ :param api_key: (required) Your ReadMe API key
54
+ :param grouping_function: (required)
55
+ Grouping function to construct an identity object. It receives the current request as a parameter, and must
56
+ return a dictionary containing at least an "id" field, and optionally "label" and "email" fields.
57
+
58
+ The main purpose of the identity object is to identify the API's caller.
59
+ :param buffer_length: (optional, default = 10) Number of requests to buffer before sending data to ReadMe.
60
+ :param development_mode: (optional, default = False) Determines whether you are running in development mode.
61
+ :param background_worker_mode: (optional, default = True)
62
+ Determines whether to issue the call to the ReadMe API in a background thread.
63
+ :param blacklist: (optional)
64
+ An array of headers and JSON body properties to skip sending to ReadMe.
65
+
66
+ If you configure a blacklist, it will override any whitelist configuration.
67
+ :param whitelist: (optional)
68
+ An array of headers and JSON body properties to send to ReadMe.
69
+
70
+ If this option is configured, ONLY the whitelisted properties will be sent.
71
+ """
72
+
73
+ self .README_API_KEY = api_key
74
+ self .GROUPING_FUNCTION = grouping_function
75
+ self .BUFFER_LENGTH = buffer_length
76
+ self .IS_DEVELOPMENT_MODE = development_mode
77
+ self .IS_BACKGROUND_MODE = background_worker_mode
78
+ self .BLACKLIST = blacklist or []
79
+ self .WHITELIST = whitelist or []
0 commit comments