21
21
from botocore .compat import OrderedDict
22
22
23
23
24
+ def _allowlist_generate_presigned_url (method_name , service_name , ** kwargs ):
25
+ if method_name != 'generate_presigned_url' :
26
+ return None
27
+ return service_name in ['s3' ]
28
+
29
+
24
30
class ClientDocumenter (object ):
31
+ _CLIENT_METHODS_FILTERS = [
32
+ _allowlist_generate_presigned_url ,
33
+ ]
34
+
25
35
def __init__ (self , client , shared_examples = None ):
26
36
self ._client = client
27
37
self ._shared_examples = shared_examples
@@ -36,10 +46,36 @@ def document_client(self, section):
36
46
"""
37
47
self ._add_title (section )
38
48
self ._add_class_signature (section )
39
- client_methods = get_instance_public_methods ( self ._client )
49
+ client_methods = self ._get_client_methods ( )
40
50
self ._add_client_intro (section , client_methods )
41
51
self ._add_client_methods (section , client_methods )
42
52
53
+ def _get_client_methods (self ):
54
+ client_methods = get_instance_public_methods (self ._client )
55
+ return self ._filter_client_methods (client_methods )
56
+
57
+ def _filter_client_methods (self , client_methods ):
58
+ filtered_methods = {}
59
+ for method_name , method in client_methods .items ():
60
+ include = self ._filter_client_method (
61
+ method = method ,
62
+ method_name = method_name ,
63
+ service_name = self ._service_name ,
64
+ )
65
+ if include :
66
+ filtered_methods [method_name ] = method
67
+ return filtered_methods
68
+
69
+ def _filter_client_method (self , ** kwargs ):
70
+ # Apply each filter to the method
71
+ for filter in self ._CLIENT_METHODS_FILTERS :
72
+ filter_include = filter (** kwargs )
73
+ # Use the first non-None value returned by any of the filters
74
+ if filter_include is not None :
75
+ return filter_include
76
+ # Otherwise default to including it
77
+ return True
78
+
43
79
def _add_title (self , section ):
44
80
section .style .h2 ('Client' )
45
81
0 commit comments