Request parameters typings (#748)

This commit is contained in:
Tomas Della Vedova
2019-01-11 14:08:49 +01:00
committed by GitHub
parent 41109f0bc0
commit f56ae1a70d
6 changed files with 2411 additions and 428 deletions

1895
api/requestParams.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

850
index.d.ts vendored
View File

@ -6,16 +6,17 @@ import Transport, { ApiResponse, EventMeta, SniffMeta, RequestOptions } from './
import Connection, { AgentOptions } from './lib/Connection';
import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool';
import Serializer from './lib/Serializer';
import * as RequestParams from './api/requestParams'
declare type anyObject = {
[key: string]: any;
};
declare type callbackFn = (err: Error | null, result: ApiResponse) => void;
interface ApiMethod {
interface ApiMethod<T> {
(callback?: callbackFn): any;
(params: anyObject, callback?: callbackFn): any;
(params: anyObject, options: RequestOptions, callback?: callbackFn): any;
(params: T, callback?: callbackFn): any;
(params: T, options: RequestOptions, callback?: callbackFn): any;
}
interface ClientOptions {
@ -45,428 +46,428 @@ declare class Client extends EventEmitter {
connectionPool: ConnectionPool;
transport: Transport;
serializer: Serializer
bulk: ApiMethod
cat: {
aliases: ApiMethod
allocation: ApiMethod
count: ApiMethod
fielddata: ApiMethod
health: ApiMethod
help: ApiMethod
indices: ApiMethod
master: ApiMethod
nodeattrs: ApiMethod
nodes: ApiMethod
pending_tasks: ApiMethod
pendingTasks: ApiMethod
plugins: ApiMethod
recovery: ApiMethod
repositories: ApiMethod
segments: ApiMethod
shards: ApiMethod
snapshots: ApiMethod
tasks: ApiMethod
templates: ApiMethod
thread_pool: ApiMethod
threadPool: ApiMethod
}
ccr: {
delete_auto_follow_pattern: ApiMethod
deleteAutoFollowPattern: ApiMethod
follow: ApiMethod
follow_stats: ApiMethod
followStats: ApiMethod
get_auto_follow_pattern: ApiMethod
getAutoFollowPattern: ApiMethod
pause_follow: ApiMethod
pauseFollow: ApiMethod
put_auto_follow_pattern: ApiMethod
putAutoFollowPattern: ApiMethod
resume_follow: ApiMethod
resumeFollow: ApiMethod
stats: ApiMethod
unfollow: ApiMethod
}
clear_scroll: ApiMethod
clearScroll: ApiMethod
cluster: {
allocation_explain: ApiMethod
allocationExplain: ApiMethod
get_settings: ApiMethod
getSettings: ApiMethod
health: ApiMethod
pending_tasks: ApiMethod
pendingTasks: ApiMethod
put_settings: ApiMethod
putSettings: ApiMethod
remote_info: ApiMethod
remoteInfo: ApiMethod
reroute: ApiMethod
state: ApiMethod
stats: ApiMethod
}
count: ApiMethod
create: ApiMethod
delete: ApiMethod
delete_by_query: ApiMethod
deleteByQuery: ApiMethod
delete_by_query_rethrottle: ApiMethod
deleteByQueryRethrottle: ApiMethod
delete_script: ApiMethod
deleteScript: ApiMethod
exists: ApiMethod
exists_source: ApiMethod
existsSource: ApiMethod
explain: ApiMethod
field_caps: ApiMethod
fieldCaps: ApiMethod
get: ApiMethod
get_script: ApiMethod
getScript: ApiMethod
get_source: ApiMethod
getSource: ApiMethod
index: ApiMethod
indices: {
analyze: ApiMethod
clear_cache: ApiMethod
clearCache: ApiMethod
close: ApiMethod
create: ApiMethod
delete: ApiMethod
delete_alias: ApiMethod
deleteAlias: ApiMethod
delete_template: ApiMethod
deleteTemplate: ApiMethod
exists: ApiMethod
exists_alias: ApiMethod
existsAlias: ApiMethod
exists_template: ApiMethod
existsTemplate: ApiMethod
exists_type: ApiMethod
existsType: ApiMethod
flush: ApiMethod
flush_synced: ApiMethod
flushSynced: ApiMethod
forcemerge: ApiMethod
get: ApiMethod
get_alias: ApiMethod
getAlias: ApiMethod
get_field_mapping: ApiMethod
getFieldMapping: ApiMethod
get_mapping: ApiMethod
getMapping: ApiMethod
get_settings: ApiMethod
getSettings: ApiMethod
get_template: ApiMethod
getTemplate: ApiMethod
get_upgrade: ApiMethod
getUpgrade: ApiMethod
open: ApiMethod
put_alias: ApiMethod
putAlias: ApiMethod
put_mapping: ApiMethod
putMapping: ApiMethod
put_settings: ApiMethod
putSettings: ApiMethod
put_template: ApiMethod
putTemplate: ApiMethod
recovery: ApiMethod
refresh: ApiMethod
rollover: ApiMethod
segments: ApiMethod
shard_stores: ApiMethod
shardStores: ApiMethod
shrink: ApiMethod
split: ApiMethod
stats: ApiMethod
update_aliases: ApiMethod
updateAliases: ApiMethod
upgrade: ApiMethod
validate_query: ApiMethod
validateQuery: ApiMethod
}
info: ApiMethod
ingest: {
delete_pipeline: ApiMethod
deletePipeline: ApiMethod
get_pipeline: ApiMethod
getPipeline: ApiMethod
processor_grok: ApiMethod
processorGrok: ApiMethod
put_pipeline: ApiMethod
putPipeline: ApiMethod
simulate: ApiMethod
}
mget: ApiMethod
msearch: ApiMethod
msearch_template: ApiMethod
msearchTemplate: ApiMethod
mtermvectors: ApiMethod
nodes: {
hot_threads: ApiMethod
hotThreads: ApiMethod
info: ApiMethod
reload_secure_settings: ApiMethod
reloadSecureSettings: ApiMethod
stats: ApiMethod
usage: ApiMethod
}
ping: ApiMethod
put_script: ApiMethod
putScript: ApiMethod
rank_eval: ApiMethod
rankEval: ApiMethod
reindex: ApiMethod
reindex_rethrottle: ApiMethod
reindexRethrottle: ApiMethod
render_search_template: ApiMethod
renderSearchTemplate: ApiMethod
scripts_painless_execute: ApiMethod
scriptsPainlessExecute: ApiMethod
scroll: ApiMethod
search: ApiMethod
search_shards: ApiMethod
searchShards: ApiMethod
search_template: ApiMethod
searchTemplate: ApiMethod
snapshot: {
create: ApiMethod
create_repository: ApiMethod
createRepository: ApiMethod
delete: ApiMethod
delete_repository: ApiMethod
deleteRepository: ApiMethod
get: ApiMethod
get_repository: ApiMethod
getRepository: ApiMethod
restore: ApiMethod
status: ApiMethod
verify_repository: ApiMethod
verifyRepository: ApiMethod
}
tasks: {
cancel: ApiMethod
get: ApiMethod
list: ApiMethod
}
termvectors: ApiMethod
update: ApiMethod
update_by_query: ApiMethod
updateByQuery: ApiMethod
update_by_query_rethrottle: ApiMethod
updateByQueryRethrottle: ApiMethod
xpack: {
graph: {
explore: ApiMethod
}
info: ApiMethod
license: {
delete: ApiMethod
get: ApiMethod
get_basic_status: ApiMethod
getBasicStatus: ApiMethod
get_trial_status: ApiMethod
getTrialStatus: ApiMethod
post: ApiMethod
post_start_basic: ApiMethod
postStartBasic: ApiMethod
post_start_trial: ApiMethod
postStartTrial: ApiMethod
}
migration: {
deprecations: ApiMethod
get_assistance: ApiMethod
getAssistance: ApiMethod
upgrade: ApiMethod
}
ml: {
close_job: ApiMethod
closeJob: ApiMethod
delete_calendar: ApiMethod
deleteCalendar: ApiMethod
delete_calendar_event: ApiMethod
deleteCalendarEvent: ApiMethod
delete_calendar_job: ApiMethod
deleteCalendarJob: ApiMethod
delete_datafeed: ApiMethod
deleteDatafeed: ApiMethod
delete_expired_data: ApiMethod
deleteExpiredData: ApiMethod
delete_filter: ApiMethod
deleteFilter: ApiMethod
delete_forecast: ApiMethod
deleteForecast: ApiMethod
delete_job: ApiMethod
deleteJob: ApiMethod
delete_model_snapshot: ApiMethod
deleteModelSnapshot: ApiMethod
find_file_structure: ApiMethod
findFileStructure: ApiMethod
flush_job: ApiMethod
flushJob: ApiMethod
forecast: ApiMethod
get_buckets: ApiMethod
getBuckets: ApiMethod
get_calendar_events: ApiMethod
getCalendarEvents: ApiMethod
get_calendars: ApiMethod
getCalendars: ApiMethod
get_categories: ApiMethod
getCategories: ApiMethod
get_datafeed_stats: ApiMethod
getDatafeedStats: ApiMethod
get_datafeeds: ApiMethod
getDatafeeds: ApiMethod
get_filters: ApiMethod
getFilters: ApiMethod
get_influencers: ApiMethod
getInfluencers: ApiMethod
get_job_stats: ApiMethod
getJobStats: ApiMethod
get_jobs: ApiMethod
getJobs: ApiMethod
get_model_snapshots: ApiMethod
getModelSnapshots: ApiMethod
get_overall_buckets: ApiMethod
getOverallBuckets: ApiMethod
get_records: ApiMethod
getRecords: ApiMethod
info: ApiMethod
open_job: ApiMethod
openJob: ApiMethod
post_calendar_events: ApiMethod
postCalendarEvents: ApiMethod
post_data: ApiMethod
postData: ApiMethod
preview_datafeed: ApiMethod
previewDatafeed: ApiMethod
put_calendar: ApiMethod
putCalendar: ApiMethod
put_calendar_job: ApiMethod
putCalendarJob: ApiMethod
put_datafeed: ApiMethod
putDatafeed: ApiMethod
put_filter: ApiMethod
putFilter: ApiMethod
put_job: ApiMethod
putJob: ApiMethod
revert_model_snapshot: ApiMethod
revertModelSnapshot: ApiMethod
start_datafeed: ApiMethod
startDatafeed: ApiMethod
stop_datafeed: ApiMethod
stopDatafeed: ApiMethod
update_datafeed: ApiMethod
updateDatafeed: ApiMethod
update_filter: ApiMethod
updateFilter: ApiMethod
update_job: ApiMethod
updateJob: ApiMethod
update_model_snapshot: ApiMethod
updateModelSnapshot: ApiMethod
validate: ApiMethod
validate_detector: ApiMethod
validateDetector: ApiMethod
}
monitoring: {
bulk: ApiMethod
}
rollup: {
delete_job: ApiMethod
deleteJob: ApiMethod
get_jobs: ApiMethod
getJobs: ApiMethod
get_rollup_caps: ApiMethod
getRollupCaps: ApiMethod
get_rollup_index_caps: ApiMethod
getRollupIndexCaps: ApiMethod
put_job: ApiMethod
putJob: ApiMethod
rollup_search: ApiMethod
rollupSearch: ApiMethod
start_job: ApiMethod
startJob: ApiMethod
stop_job: ApiMethod
stopJob: ApiMethod
}
security: {
authenticate: ApiMethod
change_password: ApiMethod
changePassword: ApiMethod
clear_cached_realms: ApiMethod
clearCachedRealms: ApiMethod
clear_cached_roles: ApiMethod
clearCachedRoles: ApiMethod
delete_privileges: ApiMethod
deletePrivileges: ApiMethod
delete_role: ApiMethod
deleteRole: ApiMethod
delete_role_mapping: ApiMethod
deleteRoleMapping: ApiMethod
delete_user: ApiMethod
deleteUser: ApiMethod
disable_user: ApiMethod
disableUser: ApiMethod
enable_user: ApiMethod
enableUser: ApiMethod
get_privileges: ApiMethod
getPrivileges: ApiMethod
get_role: ApiMethod
getRole: ApiMethod
get_role_mapping: ApiMethod
getRoleMapping: ApiMethod
get_token: ApiMethod
getToken: ApiMethod
get_user: ApiMethod
getUser: ApiMethod
get_user_privileges: ApiMethod
getUserPrivileges: ApiMethod
has_privileges: ApiMethod
hasPrivileges: ApiMethod
invalidate_token: ApiMethod
invalidateToken: ApiMethod
put_privileges: ApiMethod
putPrivileges: ApiMethod
put_role: ApiMethod
putRole: ApiMethod
put_role_mapping: ApiMethod
putRoleMapping: ApiMethod
put_user: ApiMethod
putUser: ApiMethod
}
sql: {
clear_cursor: ApiMethod
clearCursor: ApiMethod
query: ApiMethod
translate: ApiMethod
}
ssl: {
certificates: ApiMethod
}
usage: ApiMethod
watcher: {
ack_watch: ApiMethod
ackWatch: ApiMethod
activate_watch: ApiMethod
activateWatch: ApiMethod
deactivate_watch: ApiMethod
deactivateWatch: ApiMethod
delete_watch: ApiMethod
deleteWatch: ApiMethod
execute_watch: ApiMethod
executeWatch: ApiMethod
get_watch: ApiMethod
getWatch: ApiMethod
put_watch: ApiMethod
putWatch: ApiMethod
restart: ApiMethod
start: ApiMethod
stats: ApiMethod
stop: ApiMethod
}
}
constructor(opts?: ClientOptions);
close(callback?: Function): Promise<void> | void;
bulk: ApiMethod<RequestParams.Bulk>
cat: {
aliases: ApiMethod<RequestParams.CatAliases>
allocation: ApiMethod<RequestParams.CatAllocation>
count: ApiMethod<RequestParams.CatCount>
fielddata: ApiMethod<RequestParams.CatFielddata>
health: ApiMethod<RequestParams.CatHealth>
help: ApiMethod<RequestParams.CatHelp>
indices: ApiMethod<RequestParams.CatIndices>
master: ApiMethod<RequestParams.CatMaster>
nodeattrs: ApiMethod<RequestParams.CatNodeattrs>
nodes: ApiMethod<RequestParams.CatNodes>
pending_tasks: ApiMethod<RequestParams.CatPendingTasks>
pendingTasks: ApiMethod<RequestParams.CatPendingTasks>
plugins: ApiMethod<RequestParams.CatPlugins>
recovery: ApiMethod<RequestParams.CatRecovery>
repositories: ApiMethod<RequestParams.CatRepositories>
segments: ApiMethod<RequestParams.CatSegments>
shards: ApiMethod<RequestParams.CatShards>
snapshots: ApiMethod<RequestParams.CatSnapshots>
tasks: ApiMethod<RequestParams.CatTasks>
templates: ApiMethod<RequestParams.CatTemplates>
thread_pool: ApiMethod<RequestParams.CatThreadPool>
threadPool: ApiMethod<RequestParams.CatThreadPool>
}
ccr: {
delete_auto_follow_pattern: ApiMethod<RequestParams.CcrDeleteAutoFollowPattern>
deleteAutoFollowPattern: ApiMethod<RequestParams.CcrDeleteAutoFollowPattern>
follow: ApiMethod<RequestParams.CcrFollow>
follow_stats: ApiMethod<RequestParams.CcrFollowStats>
followStats: ApiMethod<RequestParams.CcrFollowStats>
get_auto_follow_pattern: ApiMethod<RequestParams.CcrGetAutoFollowPattern>
getAutoFollowPattern: ApiMethod<RequestParams.CcrGetAutoFollowPattern>
pause_follow: ApiMethod<RequestParams.CcrPauseFollow>
pauseFollow: ApiMethod<RequestParams.CcrPauseFollow>
put_auto_follow_pattern: ApiMethod<RequestParams.CcrPutAutoFollowPattern>
putAutoFollowPattern: ApiMethod<RequestParams.CcrPutAutoFollowPattern>
resume_follow: ApiMethod<RequestParams.CcrResumeFollow>
resumeFollow: ApiMethod<RequestParams.CcrResumeFollow>
stats: ApiMethod<RequestParams.CcrStats>
unfollow: ApiMethod<RequestParams.CcrUnfollow>
}
clear_scroll: ApiMethod<RequestParams.ClearScroll>
clearScroll: ApiMethod<RequestParams.ClearScroll>
cluster: {
allocation_explain: ApiMethod<RequestParams.ClusterAllocationExplain>
allocationExplain: ApiMethod<RequestParams.ClusterAllocationExplain>
get_settings: ApiMethod<RequestParams.ClusterGetSettings>
getSettings: ApiMethod<RequestParams.ClusterGetSettings>
health: ApiMethod<RequestParams.ClusterHealth>
pending_tasks: ApiMethod<RequestParams.ClusterPendingTasks>
pendingTasks: ApiMethod<RequestParams.ClusterPendingTasks>
put_settings: ApiMethod<RequestParams.ClusterPutSettings>
putSettings: ApiMethod<RequestParams.ClusterPutSettings>
remote_info: ApiMethod<RequestParams.ClusterRemoteInfo>
remoteInfo: ApiMethod<RequestParams.ClusterRemoteInfo>
reroute: ApiMethod<RequestParams.ClusterReroute>
state: ApiMethod<RequestParams.ClusterState>
stats: ApiMethod<RequestParams.ClusterStats>
}
count: ApiMethod<RequestParams.Count>
create: ApiMethod<RequestParams.Create>
delete: ApiMethod<RequestParams.Delete>
delete_by_query: ApiMethod<RequestParams.DeleteByQuery>
deleteByQuery: ApiMethod<RequestParams.DeleteByQuery>
delete_by_query_rethrottle: ApiMethod<RequestParams.DeleteByQueryRethrottle>
deleteByQueryRethrottle: ApiMethod<RequestParams.DeleteByQueryRethrottle>
delete_script: ApiMethod<RequestParams.DeleteScript>
deleteScript: ApiMethod<RequestParams.DeleteScript>
exists: ApiMethod<RequestParams.Exists>
exists_source: ApiMethod<RequestParams.ExistsSource>
existsSource: ApiMethod<RequestParams.ExistsSource>
explain: ApiMethod<RequestParams.Explain>
field_caps: ApiMethod<RequestParams.FieldCaps>
fieldCaps: ApiMethod<RequestParams.FieldCaps>
get: ApiMethod<RequestParams.Get>
get_script: ApiMethod<RequestParams.GetScript>
getScript: ApiMethod<RequestParams.GetScript>
get_source: ApiMethod<RequestParams.GetSource>
getSource: ApiMethod<RequestParams.GetSource>
index: ApiMethod<RequestParams.Index>
indices: {
analyze: ApiMethod<RequestParams.IndicesAnalyze>
clear_cache: ApiMethod<RequestParams.IndicesClearCache>
clearCache: ApiMethod<RequestParams.IndicesClearCache>
close: ApiMethod<RequestParams.IndicesClose>
create: ApiMethod<RequestParams.IndicesCreate>
delete: ApiMethod<RequestParams.IndicesDelete>
delete_alias: ApiMethod<RequestParams.IndicesDeleteAlias>
deleteAlias: ApiMethod<RequestParams.IndicesDeleteAlias>
delete_template: ApiMethod<RequestParams.IndicesDeleteTemplate>
deleteTemplate: ApiMethod<RequestParams.IndicesDeleteTemplate>
exists: ApiMethod<RequestParams.IndicesExists>
exists_alias: ApiMethod<RequestParams.IndicesExistsAlias>
existsAlias: ApiMethod<RequestParams.IndicesExistsAlias>
exists_template: ApiMethod<RequestParams.IndicesExistsTemplate>
existsTemplate: ApiMethod<RequestParams.IndicesExistsTemplate>
exists_type: ApiMethod<RequestParams.IndicesExistsType>
existsType: ApiMethod<RequestParams.IndicesExistsType>
flush: ApiMethod<RequestParams.IndicesFlush>
flush_synced: ApiMethod<RequestParams.IndicesFlushSynced>
flushSynced: ApiMethod<RequestParams.IndicesFlushSynced>
forcemerge: ApiMethod<RequestParams.IndicesForcemerge>
get: ApiMethod<RequestParams.IndicesGet>
get_alias: ApiMethod<RequestParams.IndicesGetAlias>
getAlias: ApiMethod<RequestParams.IndicesGetAlias>
get_field_mapping: ApiMethod<RequestParams.IndicesGetFieldMapping>
getFieldMapping: ApiMethod<RequestParams.IndicesGetFieldMapping>
get_mapping: ApiMethod<RequestParams.IndicesGetMapping>
getMapping: ApiMethod<RequestParams.IndicesGetMapping>
get_settings: ApiMethod<RequestParams.IndicesGetSettings>
getSettings: ApiMethod<RequestParams.IndicesGetSettings>
get_template: ApiMethod<RequestParams.IndicesGetTemplate>
getTemplate: ApiMethod<RequestParams.IndicesGetTemplate>
get_upgrade: ApiMethod<RequestParams.IndicesGetUpgrade>
getUpgrade: ApiMethod<RequestParams.IndicesGetUpgrade>
open: ApiMethod<RequestParams.IndicesOpen>
put_alias: ApiMethod<RequestParams.IndicesPutAlias>
putAlias: ApiMethod<RequestParams.IndicesPutAlias>
put_mapping: ApiMethod<RequestParams.IndicesPutMapping>
putMapping: ApiMethod<RequestParams.IndicesPutMapping>
put_settings: ApiMethod<RequestParams.IndicesPutSettings>
putSettings: ApiMethod<RequestParams.IndicesPutSettings>
put_template: ApiMethod<RequestParams.IndicesPutTemplate>
putTemplate: ApiMethod<RequestParams.IndicesPutTemplate>
recovery: ApiMethod<RequestParams.IndicesRecovery>
refresh: ApiMethod<RequestParams.IndicesRefresh>
rollover: ApiMethod<RequestParams.IndicesRollover>
segments: ApiMethod<RequestParams.IndicesSegments>
shard_stores: ApiMethod<RequestParams.IndicesShardStores>
shardStores: ApiMethod<RequestParams.IndicesShardStores>
shrink: ApiMethod<RequestParams.IndicesShrink>
split: ApiMethod<RequestParams.IndicesSplit>
stats: ApiMethod<RequestParams.IndicesStats>
update_aliases: ApiMethod<RequestParams.IndicesUpdateAliases>
updateAliases: ApiMethod<RequestParams.IndicesUpdateAliases>
upgrade: ApiMethod<RequestParams.IndicesUpgrade>
validate_query: ApiMethod<RequestParams.IndicesValidateQuery>
validateQuery: ApiMethod<RequestParams.IndicesValidateQuery>
}
info: ApiMethod<RequestParams.Info>
ingest: {
delete_pipeline: ApiMethod<RequestParams.IngestDeletePipeline>
deletePipeline: ApiMethod<RequestParams.IngestDeletePipeline>
get_pipeline: ApiMethod<RequestParams.IngestGetPipeline>
getPipeline: ApiMethod<RequestParams.IngestGetPipeline>
processor_grok: ApiMethod<RequestParams.IngestProcessorGrok>
processorGrok: ApiMethod<RequestParams.IngestProcessorGrok>
put_pipeline: ApiMethod<RequestParams.IngestPutPipeline>
putPipeline: ApiMethod<RequestParams.IngestPutPipeline>
simulate: ApiMethod<RequestParams.IngestSimulate>
}
mget: ApiMethod<RequestParams.Mget>
msearch: ApiMethod<RequestParams.Msearch>
msearch_template: ApiMethod<RequestParams.MsearchTemplate>
msearchTemplate: ApiMethod<RequestParams.MsearchTemplate>
mtermvectors: ApiMethod<RequestParams.Mtermvectors>
nodes: {
hot_threads: ApiMethod<RequestParams.NodesHotThreads>
hotThreads: ApiMethod<RequestParams.NodesHotThreads>
info: ApiMethod<RequestParams.NodesInfo>
reload_secure_settings: ApiMethod<RequestParams.NodesReloadSecureSettings>
reloadSecureSettings: ApiMethod<RequestParams.NodesReloadSecureSettings>
stats: ApiMethod<RequestParams.NodesStats>
usage: ApiMethod<RequestParams.NodesUsage>
}
ping: ApiMethod<RequestParams.Ping>
put_script: ApiMethod<RequestParams.PutScript>
putScript: ApiMethod<RequestParams.PutScript>
rank_eval: ApiMethod<RequestParams.RankEval>
rankEval: ApiMethod<RequestParams.RankEval>
reindex: ApiMethod<RequestParams.Reindex>
reindex_rethrottle: ApiMethod<RequestParams.ReindexRethrottle>
reindexRethrottle: ApiMethod<RequestParams.ReindexRethrottle>
render_search_template: ApiMethod<RequestParams.RenderSearchTemplate>
renderSearchTemplate: ApiMethod<RequestParams.RenderSearchTemplate>
scripts_painless_execute: ApiMethod<RequestParams.ScriptsPainlessExecute>
scriptsPainlessExecute: ApiMethod<RequestParams.ScriptsPainlessExecute>
scroll: ApiMethod<RequestParams.Scroll>
search: ApiMethod<RequestParams.Search>
search_shards: ApiMethod<RequestParams.SearchShards>
searchShards: ApiMethod<RequestParams.SearchShards>
search_template: ApiMethod<RequestParams.SearchTemplate>
searchTemplate: ApiMethod<RequestParams.SearchTemplate>
snapshot: {
create: ApiMethod<RequestParams.SnapshotCreate>
create_repository: ApiMethod<RequestParams.SnapshotCreateRepository>
createRepository: ApiMethod<RequestParams.SnapshotCreateRepository>
delete: ApiMethod<RequestParams.SnapshotDelete>
delete_repository: ApiMethod<RequestParams.SnapshotDeleteRepository>
deleteRepository: ApiMethod<RequestParams.SnapshotDeleteRepository>
get: ApiMethod<RequestParams.SnapshotGet>
get_repository: ApiMethod<RequestParams.SnapshotGetRepository>
getRepository: ApiMethod<RequestParams.SnapshotGetRepository>
restore: ApiMethod<RequestParams.SnapshotRestore>
status: ApiMethod<RequestParams.SnapshotStatus>
verify_repository: ApiMethod<RequestParams.SnapshotVerifyRepository>
verifyRepository: ApiMethod<RequestParams.SnapshotVerifyRepository>
}
tasks: {
cancel: ApiMethod<RequestParams.TasksCancel>
get: ApiMethod<RequestParams.TasksGet>
list: ApiMethod<RequestParams.TasksList>
}
termvectors: ApiMethod<RequestParams.Termvectors>
update: ApiMethod<RequestParams.Update>
update_by_query: ApiMethod<RequestParams.UpdateByQuery>
updateByQuery: ApiMethod<RequestParams.UpdateByQuery>
update_by_query_rethrottle: ApiMethod<RequestParams.UpdateByQueryRethrottle>
updateByQueryRethrottle: ApiMethod<RequestParams.UpdateByQueryRethrottle>
xpack: {
graph: {
explore: ApiMethod<RequestParams.XpackGraphExplore>
}
info: ApiMethod<RequestParams.XpackInfo>
license: {
delete: ApiMethod<RequestParams.XpackLicenseDelete>
get: ApiMethod<RequestParams.XpackLicenseGet>
get_basic_status: ApiMethod<RequestParams.XpackLicenseGetBasicStatus>
getBasicStatus: ApiMethod<RequestParams.XpackLicenseGetBasicStatus>
get_trial_status: ApiMethod<RequestParams.XpackLicenseGetTrialStatus>
getTrialStatus: ApiMethod<RequestParams.XpackLicenseGetTrialStatus>
post: ApiMethod<RequestParams.XpackLicensePost>
post_start_basic: ApiMethod<RequestParams.XpackLicensePostStartBasic>
postStartBasic: ApiMethod<RequestParams.XpackLicensePostStartBasic>
post_start_trial: ApiMethod<RequestParams.XpackLicensePostStartTrial>
postStartTrial: ApiMethod<RequestParams.XpackLicensePostStartTrial>
}
migration: {
deprecations: ApiMethod<RequestParams.XpackMigrationDeprecations>
get_assistance: ApiMethod<RequestParams.XpackMigrationGetAssistance>
getAssistance: ApiMethod<RequestParams.XpackMigrationGetAssistance>
upgrade: ApiMethod<RequestParams.XpackMigrationUpgrade>
}
ml: {
close_job: ApiMethod<RequestParams.XpackMlCloseJob>
closeJob: ApiMethod<RequestParams.XpackMlCloseJob>
delete_calendar: ApiMethod<RequestParams.XpackMlDeleteCalendar>
deleteCalendar: ApiMethod<RequestParams.XpackMlDeleteCalendar>
delete_calendar_event: ApiMethod<RequestParams.XpackMlDeleteCalendarEvent>
deleteCalendarEvent: ApiMethod<RequestParams.XpackMlDeleteCalendarEvent>
delete_calendar_job: ApiMethod<RequestParams.XpackMlDeleteCalendarJob>
deleteCalendarJob: ApiMethod<RequestParams.XpackMlDeleteCalendarJob>
delete_datafeed: ApiMethod<RequestParams.XpackMlDeleteDatafeed>
deleteDatafeed: ApiMethod<RequestParams.XpackMlDeleteDatafeed>
delete_expired_data: ApiMethod<RequestParams.XpackMlDeleteExpiredData>
deleteExpiredData: ApiMethod<RequestParams.XpackMlDeleteExpiredData>
delete_filter: ApiMethod<RequestParams.XpackMlDeleteFilter>
deleteFilter: ApiMethod<RequestParams.XpackMlDeleteFilter>
delete_forecast: ApiMethod<RequestParams.XpackMlDeleteForecast>
deleteForecast: ApiMethod<RequestParams.XpackMlDeleteForecast>
delete_job: ApiMethod<RequestParams.XpackMlDeleteJob>
deleteJob: ApiMethod<RequestParams.XpackMlDeleteJob>
delete_model_snapshot: ApiMethod<RequestParams.XpackMlDeleteModelSnapshot>
deleteModelSnapshot: ApiMethod<RequestParams.XpackMlDeleteModelSnapshot>
find_file_structure: ApiMethod<RequestParams.XpackMlFindFileStructure>
findFileStructure: ApiMethod<RequestParams.XpackMlFindFileStructure>
flush_job: ApiMethod<RequestParams.XpackMlFlushJob>
flushJob: ApiMethod<RequestParams.XpackMlFlushJob>
forecast: ApiMethod<RequestParams.XpackMlForecast>
get_buckets: ApiMethod<RequestParams.XpackMlGetBuckets>
getBuckets: ApiMethod<RequestParams.XpackMlGetBuckets>
get_calendar_events: ApiMethod<RequestParams.XpackMlGetCalendarEvents>
getCalendarEvents: ApiMethod<RequestParams.XpackMlGetCalendarEvents>
get_calendars: ApiMethod<RequestParams.XpackMlGetCalendars>
getCalendars: ApiMethod<RequestParams.XpackMlGetCalendars>
get_categories: ApiMethod<RequestParams.XpackMlGetCategories>
getCategories: ApiMethod<RequestParams.XpackMlGetCategories>
get_datafeed_stats: ApiMethod<RequestParams.XpackMlGetDatafeedStats>
getDatafeedStats: ApiMethod<RequestParams.XpackMlGetDatafeedStats>
get_datafeeds: ApiMethod<RequestParams.XpackMlGetDatafeeds>
getDatafeeds: ApiMethod<RequestParams.XpackMlGetDatafeeds>
get_filters: ApiMethod<RequestParams.XpackMlGetFilters>
getFilters: ApiMethod<RequestParams.XpackMlGetFilters>
get_influencers: ApiMethod<RequestParams.XpackMlGetInfluencers>
getInfluencers: ApiMethod<RequestParams.XpackMlGetInfluencers>
get_job_stats: ApiMethod<RequestParams.XpackMlGetJobStats>
getJobStats: ApiMethod<RequestParams.XpackMlGetJobStats>
get_jobs: ApiMethod<RequestParams.XpackMlGetJobs>
getJobs: ApiMethod<RequestParams.XpackMlGetJobs>
get_model_snapshots: ApiMethod<RequestParams.XpackMlGetModelSnapshots>
getModelSnapshots: ApiMethod<RequestParams.XpackMlGetModelSnapshots>
get_overall_buckets: ApiMethod<RequestParams.XpackMlGetOverallBuckets>
getOverallBuckets: ApiMethod<RequestParams.XpackMlGetOverallBuckets>
get_records: ApiMethod<RequestParams.XpackMlGetRecords>
getRecords: ApiMethod<RequestParams.XpackMlGetRecords>
info: ApiMethod<RequestParams.XpackMlInfo>
open_job: ApiMethod<RequestParams.XpackMlOpenJob>
openJob: ApiMethod<RequestParams.XpackMlOpenJob>
post_calendar_events: ApiMethod<RequestParams.XpackMlPostCalendarEvents>
postCalendarEvents: ApiMethod<RequestParams.XpackMlPostCalendarEvents>
post_data: ApiMethod<RequestParams.XpackMlPostData>
postData: ApiMethod<RequestParams.XpackMlPostData>
preview_datafeed: ApiMethod<RequestParams.XpackMlPreviewDatafeed>
previewDatafeed: ApiMethod<RequestParams.XpackMlPreviewDatafeed>
put_calendar: ApiMethod<RequestParams.XpackMlPutCalendar>
putCalendar: ApiMethod<RequestParams.XpackMlPutCalendar>
put_calendar_job: ApiMethod<RequestParams.XpackMlPutCalendarJob>
putCalendarJob: ApiMethod<RequestParams.XpackMlPutCalendarJob>
put_datafeed: ApiMethod<RequestParams.XpackMlPutDatafeed>
putDatafeed: ApiMethod<RequestParams.XpackMlPutDatafeed>
put_filter: ApiMethod<RequestParams.XpackMlPutFilter>
putFilter: ApiMethod<RequestParams.XpackMlPutFilter>
put_job: ApiMethod<RequestParams.XpackMlPutJob>
putJob: ApiMethod<RequestParams.XpackMlPutJob>
revert_model_snapshot: ApiMethod<RequestParams.XpackMlRevertModelSnapshot>
revertModelSnapshot: ApiMethod<RequestParams.XpackMlRevertModelSnapshot>
start_datafeed: ApiMethod<RequestParams.XpackMlStartDatafeed>
startDatafeed: ApiMethod<RequestParams.XpackMlStartDatafeed>
stop_datafeed: ApiMethod<RequestParams.XpackMlStopDatafeed>
stopDatafeed: ApiMethod<RequestParams.XpackMlStopDatafeed>
update_datafeed: ApiMethod<RequestParams.XpackMlUpdateDatafeed>
updateDatafeed: ApiMethod<RequestParams.XpackMlUpdateDatafeed>
update_filter: ApiMethod<RequestParams.XpackMlUpdateFilter>
updateFilter: ApiMethod<RequestParams.XpackMlUpdateFilter>
update_job: ApiMethod<RequestParams.XpackMlUpdateJob>
updateJob: ApiMethod<RequestParams.XpackMlUpdateJob>
update_model_snapshot: ApiMethod<RequestParams.XpackMlUpdateModelSnapshot>
updateModelSnapshot: ApiMethod<RequestParams.XpackMlUpdateModelSnapshot>
validate: ApiMethod<RequestParams.XpackMlValidate>
validate_detector: ApiMethod<RequestParams.XpackMlValidateDetector>
validateDetector: ApiMethod<RequestParams.XpackMlValidateDetector>
}
monitoring: {
bulk: ApiMethod<RequestParams.XpackMonitoringBulk>
}
rollup: {
delete_job: ApiMethod<RequestParams.XpackRollupDeleteJob>
deleteJob: ApiMethod<RequestParams.XpackRollupDeleteJob>
get_jobs: ApiMethod<RequestParams.XpackRollupGetJobs>
getJobs: ApiMethod<RequestParams.XpackRollupGetJobs>
get_rollup_caps: ApiMethod<RequestParams.XpackRollupGetRollupCaps>
getRollupCaps: ApiMethod<RequestParams.XpackRollupGetRollupCaps>
get_rollup_index_caps: ApiMethod<RequestParams.XpackRollupGetRollupIndexCaps>
getRollupIndexCaps: ApiMethod<RequestParams.XpackRollupGetRollupIndexCaps>
put_job: ApiMethod<RequestParams.XpackRollupPutJob>
putJob: ApiMethod<RequestParams.XpackRollupPutJob>
rollup_search: ApiMethod<RequestParams.XpackRollupRollupSearch>
rollupSearch: ApiMethod<RequestParams.XpackRollupRollupSearch>
start_job: ApiMethod<RequestParams.XpackRollupStartJob>
startJob: ApiMethod<RequestParams.XpackRollupStartJob>
stop_job: ApiMethod<RequestParams.XpackRollupStopJob>
stopJob: ApiMethod<RequestParams.XpackRollupStopJob>
}
security: {
authenticate: ApiMethod<RequestParams.XpackSecurityAuthenticate>
change_password: ApiMethod<RequestParams.XpackSecurityChangePassword>
changePassword: ApiMethod<RequestParams.XpackSecurityChangePassword>
clear_cached_realms: ApiMethod<RequestParams.XpackSecurityClearCachedRealms>
clearCachedRealms: ApiMethod<RequestParams.XpackSecurityClearCachedRealms>
clear_cached_roles: ApiMethod<RequestParams.XpackSecurityClearCachedRoles>
clearCachedRoles: ApiMethod<RequestParams.XpackSecurityClearCachedRoles>
delete_privileges: ApiMethod<RequestParams.XpackSecurityDeletePrivileges>
deletePrivileges: ApiMethod<RequestParams.XpackSecurityDeletePrivileges>
delete_role: ApiMethod<RequestParams.XpackSecurityDeleteRole>
deleteRole: ApiMethod<RequestParams.XpackSecurityDeleteRole>
delete_role_mapping: ApiMethod<RequestParams.XpackSecurityDeleteRoleMapping>
deleteRoleMapping: ApiMethod<RequestParams.XpackSecurityDeleteRoleMapping>
delete_user: ApiMethod<RequestParams.XpackSecurityDeleteUser>
deleteUser: ApiMethod<RequestParams.XpackSecurityDeleteUser>
disable_user: ApiMethod<RequestParams.XpackSecurityDisableUser>
disableUser: ApiMethod<RequestParams.XpackSecurityDisableUser>
enable_user: ApiMethod<RequestParams.XpackSecurityEnableUser>
enableUser: ApiMethod<RequestParams.XpackSecurityEnableUser>
get_privileges: ApiMethod<RequestParams.XpackSecurityGetPrivileges>
getPrivileges: ApiMethod<RequestParams.XpackSecurityGetPrivileges>
get_role: ApiMethod<RequestParams.XpackSecurityGetRole>
getRole: ApiMethod<RequestParams.XpackSecurityGetRole>
get_role_mapping: ApiMethod<RequestParams.XpackSecurityGetRoleMapping>
getRoleMapping: ApiMethod<RequestParams.XpackSecurityGetRoleMapping>
get_token: ApiMethod<RequestParams.XpackSecurityGetToken>
getToken: ApiMethod<RequestParams.XpackSecurityGetToken>
get_user: ApiMethod<RequestParams.XpackSecurityGetUser>
getUser: ApiMethod<RequestParams.XpackSecurityGetUser>
get_user_privileges: ApiMethod<RequestParams.XpackSecurityGetUserPrivileges>
getUserPrivileges: ApiMethod<RequestParams.XpackSecurityGetUserPrivileges>
has_privileges: ApiMethod<RequestParams.XpackSecurityHasPrivileges>
hasPrivileges: ApiMethod<RequestParams.XpackSecurityHasPrivileges>
invalidate_token: ApiMethod<RequestParams.XpackSecurityInvalidateToken>
invalidateToken: ApiMethod<RequestParams.XpackSecurityInvalidateToken>
put_privileges: ApiMethod<RequestParams.XpackSecurityPutPrivileges>
putPrivileges: ApiMethod<RequestParams.XpackSecurityPutPrivileges>
put_role: ApiMethod<RequestParams.XpackSecurityPutRole>
putRole: ApiMethod<RequestParams.XpackSecurityPutRole>
put_role_mapping: ApiMethod<RequestParams.XpackSecurityPutRoleMapping>
putRoleMapping: ApiMethod<RequestParams.XpackSecurityPutRoleMapping>
put_user: ApiMethod<RequestParams.XpackSecurityPutUser>
putUser: ApiMethod<RequestParams.XpackSecurityPutUser>
}
sql: {
clear_cursor: ApiMethod<RequestParams.XpackSqlClearCursor>
clearCursor: ApiMethod<RequestParams.XpackSqlClearCursor>
query: ApiMethod<RequestParams.XpackSqlQuery>
translate: ApiMethod<RequestParams.XpackSqlTranslate>
}
ssl: {
certificates: ApiMethod<RequestParams.XpackSslCertificates>
}
usage: ApiMethod<RequestParams.XpackUsage>
watcher: {
ack_watch: ApiMethod<RequestParams.XpackWatcherAckWatch>
ackWatch: ApiMethod<RequestParams.XpackWatcherAckWatch>
activate_watch: ApiMethod<RequestParams.XpackWatcherActivateWatch>
activateWatch: ApiMethod<RequestParams.XpackWatcherActivateWatch>
deactivate_watch: ApiMethod<RequestParams.XpackWatcherDeactivateWatch>
deactivateWatch: ApiMethod<RequestParams.XpackWatcherDeactivateWatch>
delete_watch: ApiMethod<RequestParams.XpackWatcherDeleteWatch>
deleteWatch: ApiMethod<RequestParams.XpackWatcherDeleteWatch>
execute_watch: ApiMethod<RequestParams.XpackWatcherExecuteWatch>
executeWatch: ApiMethod<RequestParams.XpackWatcherExecuteWatch>
get_watch: ApiMethod<RequestParams.XpackWatcherGetWatch>
getWatch: ApiMethod<RequestParams.XpackWatcherGetWatch>
put_watch: ApiMethod<RequestParams.XpackWatcherPutWatch>
putWatch: ApiMethod<RequestParams.XpackWatcherPutWatch>
restart: ApiMethod<RequestParams.XpackWatcherRestart>
start: ApiMethod<RequestParams.XpackWatcherStart>
stats: ApiMethod<RequestParams.XpackWatcherStats>
stop: ApiMethod<RequestParams.XpackWatcherStop>
}
}
}
declare const events: {
@ -486,5 +487,6 @@ export {
ApiResponse,
EventMeta,
SniffMeta,
ResurrectMeta
ResurrectMeta,
RequestParams
};

View File

@ -7,7 +7,7 @@ const semver = require('semver')
const ora = require('ora')
const rimraf = require('rimraf')
const standard = require('standard')
const { generate, cloneAndCheckout, genFactory } = require('./utils')
const { generate, cloneAndCheckout, genFactory, generateRequestTypes } = require('./utils')
start(minimist(process.argv.slice(2), {
string: ['tag']
@ -23,6 +23,8 @@ function start (opts) {
const apiOutputFolder = join(packageFolder, 'api')
const mainOutputFile = join(packageFolder, 'index.js')
const typesOutputFile = join(packageFolder, 'generated.d.ts')
const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts')
const allSpec = []
log.text = 'Cleaning API folder...'
rimraf.sync(join(apiOutputFolder, '*.js'))
@ -36,6 +38,12 @@ function start (opts) {
readdirSync(apiFolder).forEach(generateApiFile(apiFolder, log))
readdirSync(xPackFolder).forEach(generateApiFile(xPackFolder, log))
writeFileSync(
requestParamsOutputFile,
generateRequestTypes(allSpec),
{ encoding: 'utf8' }
)
const { fn: factory, types } = genFactory(apiOutputFolder)
writeFileSync(
mainOutputFile,
@ -61,6 +69,7 @@ function start (opts) {
log.text = `Processing ${file}`
const spec = require(join(apiFolder, file))
allSpec.push(spec)
const code = generate(spec, common)
const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`)

View File

@ -9,6 +9,11 @@ function genFactory (folder) {
const apiFiles = readdirSync(folder)
const types = apiFiles
.map(file => {
const name = file
.slice(0, -3)
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
return file
.slice(0, -3) // remove `.js` extension
.split('.')
@ -16,12 +21,12 @@ function genFactory (folder) {
.reduce((acc, val) => {
const obj = {
[val]: acc === null
? 'ApiMethod'
? `ApiMethod<RequestParams.${name[0].toUpperCase() + name.slice(1)}>`
: acc
}
if (isSnakeCased(val)) {
obj[camelify(val)] = acc === null
? 'ApiMethod'
? `ApiMethod<RequestParams.${name[0].toUpperCase() + name.slice(1)}>`
: acc
}
return obj

View File

@ -0,0 +1,71 @@
'use strict'
function generate (api) {
var types = `export interface Generic {
method?: string;
ignore?: number | number[];
filter_path?: string | string[];
pretty?: boolean;
human?: boolean;
error_trace?: boolean;
source?: string;
}
`
api.forEach(generateRequestType)
return types
function generateRequestType (spec) {
const api = Object.keys(spec)[0]
const name = api
.replace(/\.([a-z])/g, k => k[1].toUpperCase())
.replace(/_([a-z])/g, k => k[1].toUpperCase())
const { parts = {}, params = {} } = spec[api].url
const { body } = spec[api]
const partsArr = Object.keys(parts)
.map(k => ({ key: k, value: parts[k] }))
const paramsArr = Object.keys(params)
.filter(k => !Object.keys(parts).includes(k))
.map(k => ({ key: k, value: params[k] }))
const genLine = e => {
const optional = e.value.required ? '' : '?'
return `${e.key}${optional}: ${getType(e.value.type, e.value.options)};`
}
const code = `
export interface ${name[0].toUpperCase() + name.slice(1)} extends Generic {
${partsArr.map(genLine).join('\n ')}
${paramsArr.map(genLine).join('\n ')}
${body ? `body${body.required ? '' : '?'}: any;` : ''}
}
`
types += '\n'
// remove empty lines
types += code.replace(/^\s*\n/gm, '')
}
function getType (type, options) {
switch (type) {
case 'list':
return 'string | string[]'
case 'date':
case 'time':
case 'timeout':
return 'string'
case 'enum':
return options.map(k => `'${k}'`).join(' | ')
case 'int':
case 'double':
case 'long':
return 'number'
default:
return type
}
}
}
module.exports = generate

View File

@ -1,7 +1,8 @@
'use strict'
const generate = require('./generate')
const generateRequestTypes = require('./generateRequestTypes')
const cloneAndCheckout = require('./clone-es')
const genFactory = require('./genMain')
module.exports = { generate, cloneAndCheckout, genFactory }
module.exports = { generate, cloneAndCheckout, genFactory, generateRequestTypes }