@@ -544,7 +544,7 @@ export function hoistRequestAnnotations (
544544 request : model . Request , jsDocs : JSDoc [ ] , mappings : Record < string , model . Endpoint > , response : model . TypeName | null
545545) : void {
546546 const knownRequestAnnotations = [
547- 'since' , 'rest_spec_name' , 'stability' , 'visibility' , 'behavior' , 'class_serializer' , 'doc_id'
547+ 'since' , 'rest_spec_name' , 'stability' , 'visibility' , 'behavior' , 'class_serializer' , 'security_prerequisites_index' , 'security_prerequisites_cluster' , ' doc_id'
548548 ]
549549 // in most of the cases the jsDocs comes in a single block,
550550 // but it can happen that the user defines multiple single line jsDoc.
@@ -584,6 +584,33 @@ export function hoistRequestAnnotations (
584584 } else if ( tag === 'since' ) {
585585 assert ( jsDocs , semver . valid ( value ) , `Request ${ request . name . name } 's @since is not valid semver: ${ value } ` )
586586 endpoint . since = value
587+ } else if ( tag === 'security_prerequisites_index' ) {
588+ const privileges = [
589+ 'all' , 'auto_configure' , 'create' , 'create_doc' , 'create_index' , 'delete' , 'delete_index' , 'index' ,
590+ 'maintenance' , 'manage' , 'manage_follow_index' , 'manage_ilm' , 'manage_leader_index' , 'monitor' ,
591+ 'read' , 'read_cross_cluster' , 'view_index_metadata' , 'write'
592+ ]
593+ const values = value . split ( ',' ) . map ( v => v . trim ( ) )
594+ for ( const v of values ) {
595+ assert ( jsDocs , privileges . includes ( v ) , `The index privilege '${ v } ' does not exists.` )
596+ }
597+ endpoint . securityPrerequisites = endpoint . securityPrerequisites ?? { }
598+ endpoint . securityPrerequisites . index = values
599+ } else if ( tag === 'security_prerequisites_cluster' ) {
600+ const privileges = [
601+ 'all' , 'cancel_task' , 'create_snapshot' , 'grant_api_key' , 'manage' , 'manage_api_key' , 'manage_ccr' ,
602+ 'manage_ilm' , 'manage_index_templates' , 'manage_ingest_pipelines' , 'manage_logstash_pipelines' ,
603+ 'manage_ml' , 'manage_oidc' , 'manage_own_api_key' , 'manage_pipeline' , 'manage_rollup' , 'manage_saml' ,
604+ 'manage_security' , 'manage_service_account' , 'manage_slm' , 'manage_token' , 'manage_transform' ,
605+ 'manage_watcher' , 'monitor' , 'monitor_ml' , 'monitor_rollup' , 'monitor_snapshot' , 'monitor_text_structure' ,
606+ 'monitor_transform' , 'monitor_watcher' , 'read_ccr' , 'read_ilm' , 'read_pipeline' , 'read_slm' , 'transport_client'
607+ ]
608+ const values = value . split ( ',' ) . map ( v => v . trim ( ) )
609+ for ( const v of values ) {
610+ assert ( jsDocs , privileges . includes ( v ) , `The cluster privilege '${ v } ' does not exists.` )
611+ }
612+ endpoint . securityPrerequisites = endpoint . securityPrerequisites ?? { }
613+ endpoint . securityPrerequisites . cluster = values
587614 } else if ( tag === 'doc_id' ) {
588615 assert ( jsDocs , value . trim ( ) !== '' , `Request ${ request . name . name } 's @doc_id is cannot be empty` )
589616 endpoint . docId = value
0 commit comments