@@ -24,21 +24,38 @@ module API
2424 class EndpointSpec
2525 include EndpointSpecifics
2626
27+ # These APIs are private, but were added in 8.x since the generator didn't consider
28+ # visibility. They will be removed in 9.x since we're using a different generator that
29+ # considers visibility. But new private APIs code won't be generated for the client.
30+ EXCLUDED_8X = [
31+ 'autoscaling.delete_autoscaling_policy' , 'autoscaling.get_autoscaling_capacity' ,
32+ 'autoscaling.get_autoscaling_policy' , 'autoscaling.put_autoscaling_policy' , 'capabilities' ,
33+ 'connector.secret_delete' , 'connector.secret_get' , 'connector.secret_post' ,
34+ 'connector.secret_put' , 'fleet.delete_secret' , 'fleet.get_secret' , 'fleet.post_secret' ,
35+ 'ml.validate' , 'ml.validate_detector' , 'monitoring.bulk' , 'profiling.flamegraph' ,
36+ 'profiling.stacktraces' , 'profiling.status' , 'profiling.topn_functions' ,
37+ 'security.activate_user_profile' , 'security.disable_user_profile' ,
38+ 'security.enable_user_profile' , 'security.get_user_profile' ,
39+ 'security.has_privileges_user_profile' , 'security.suggest_user_profiles' ,
40+ 'security.update_user_profile_data' , 'shutdown.delete_node' , 'shutdown.get_node' ,
41+ 'shutdown.put_node'
42+ ] . freeze
43+
2744 def initialize ( filepath )
2845 @path = Pathname ( filepath )
2946 json = MultiJson . load ( File . read ( @path ) )
3047 @spec = json . values . first
3148 @endpoint_name = json . keys . first
3249
3350 full_namespace = parse_full_namespace
34- @namespace_depth = full_namespace . size > 0 ? full_namespace . size - 1 : 0
51+ @namespace_depth = full_namespace . size . positive? ? full_namespace . size - 1 : 0
3552 @module_namespace = full_namespace [ 0 , @namespace_depth ]
3653 @method_name = full_namespace . last
3754
3855 @path_parts = parse_endpoint_parts ( @spec )
3956 @params = @spec [ 'params' ] || { }
4057 @paths = @spec [ 'url' ] [ 'paths' ] . map { |b | b [ 'path' ] } if @spec [ 'url' ]
41- @path_params = path_variables . flatten . uniq . collect ( &:to_sym )
58+ @path_params = path_variables . flatten . uniq . collect ( &:to_sym )
4259 @http_method = parse_http_method ( @spec )
4360 @deprecation_note = @spec [ 'url' ] [ 'paths' ] . last &.[]( 'deprecated' )
4461 @http_path = parse_http_path ( @paths )
@@ -71,6 +88,16 @@ def stability
7188 @spec [ 'stability' ]
7289 end
7390
91+ def visibility
92+ @spec [ 'visibility' ]
93+ end
94+
95+ def skippable?
96+ return true if module_namespace . flatten . first == '_internal'
97+
98+ visibility != 'public' && !EXCLUDED_8X . include? ( endpoint_name )
99+ end
100+
74101 # Function that adds the listified h param code
75102 def specific_params
76103 super ( @module_namespace . first , @method_name )
0 commit comments