Skip to content

Commit 2ea3979

Browse files
authored
Fix node shutdown apis and code generation (#1697)
1 parent 5603482 commit 2ea3979

File tree

7 files changed

+281
-81
lines changed

7 files changed

+281
-81
lines changed

src/api/api/_internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class Internal {
9191
async health (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
9292
async health (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
9393
async health (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
94-
const acceptedPath: string[] = []
94+
const acceptedPath: string[] = ['component', 'feature']
9595
const querystring: Record<string, any> = {}
9696
const body = undefined
9797

src/api/api/async_search.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ export default class AsyncSearch {
130130
if (acceptedBody.includes(key)) {
131131
body = body ?? {}
132132
// @ts-expect-error
133-
if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) { // eslint-disable-line
134-
// @ts-expect-error
133+
if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) {
135134
querystring[key] = params[key]
136135
} else {
137136
// @ts-expect-error

src/api/api/cat.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ export default class Cat {
103103
return await this.transport.request({ path, method, querystring, body }, options)
104104
}
105105

106-
async componentTemplates (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
107-
async componentTemplates (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
108-
async componentTemplates (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
109-
async componentTemplates (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
106+
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest | TB.CatComponentTemplatesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CatComponentTemplatesResponse>
107+
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest | TB.CatComponentTemplatesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CatComponentTemplatesResponse, unknown>>
108+
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest | TB.CatComponentTemplatesRequest, options?: TransportRequestOptions): Promise<T.CatComponentTemplatesResponse>
109+
async componentTemplates (this: That, params?: T.CatComponentTemplatesRequest | TB.CatComponentTemplatesRequest, options?: TransportRequestOptions): Promise<any> {
110110
const acceptedPath: string[] = ['name']
111111
const querystring: Record<string, any> = {}
112112
const body = undefined
@@ -116,6 +116,7 @@ export default class Cat {
116116
if (acceptedPath.includes(key)) {
117117
continue
118118
} else if (key !== 'body') {
119+
// @ts-expect-error
119120
querystring[key] = params[key]
120121
}
121122
}

src/api/api/search.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ export default async function SearchApi<TDocument = unknown, TAggregations = Rec
5858
if (acceptedBody.includes(key)) {
5959
body = body ?? {}
6060
// @ts-expect-error
61-
if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) { // eslint-disable-line
62-
// @ts-expect-error
61+
if (key === 'sort' && typeof params[key] === 'string' && params[key].includes(':')) {
6362
querystring[key] = params[key]
6463
} else {
6564
// @ts-expect-error

src/api/api/shutdown.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,23 @@ export default class Shutdown {
100100
async putNode (this: That, params: T.ShutdownPutNodeRequest | TB.ShutdownPutNodeRequest, options?: TransportRequestOptions): Promise<T.ShutdownPutNodeResponse>
101101
async putNode (this: That, params: T.ShutdownPutNodeRequest | TB.ShutdownPutNodeRequest, options?: TransportRequestOptions): Promise<any> {
102102
const acceptedPath: string[] = ['node_id']
103+
const acceptedBody: string[] = ['type', 'reason', 'allocation_delay', 'target_node_name']
103104
const querystring: Record<string, any> = {}
104-
const body = undefined
105+
// @ts-expect-error
106+
const userBody: any = params?.body
107+
let body: Record<string, any> | string
108+
if (typeof userBody === 'string') {
109+
body = userBody
110+
} else {
111+
body = userBody != null ? { ...userBody } : undefined
112+
}
105113

106114
for (const key in params) {
107-
if (acceptedPath.includes(key)) {
115+
if (acceptedBody.includes(key)) {
116+
body = body ?? {}
117+
// @ts-expect-error
118+
body[key] = params[key]
119+
} else if (acceptedPath.includes(key)) {
108120
continue
109121
} else if (key !== 'body') {
110122
// @ts-expect-error

0 commit comments

Comments
 (0)