Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 259 additions & 25 deletions docs/reference/api-reference.md

Large diffs are not rendered by default.

26 changes: 20 additions & 6 deletions src/api/api/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@ const acceptedParams: Record<string, { path: string[], body: string[], query: st
capabilities: {
path: [],
body: [],
query: []
query: [
'method',
'path',
'parameters',
'capabilities',
'local_only',
'timeout'
]
}
}

/**
* Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported
* Checks if the specified combination of method, API, parameters, and arbitrary capabilities are supported.
* @see {@link https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc#require-or-skip-api-capabilities | Elasticsearch API documentation}
*/
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
export default async function CapabilitiesApi (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
export default async function CapabilitiesApi (this: That, params?: T.CapabilitiesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.CapabilitiesResponse>
export default async function CapabilitiesApi (this: That, params?: T.CapabilitiesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.CapabilitiesResponse, unknown>>
export default async function CapabilitiesApi (this: That, params?: T.CapabilitiesRequest, options?: TransportRequestOptions): Promise<T.CapabilitiesResponse>
export default async function CapabilitiesApi (this: That, params?: T.CapabilitiesRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = acceptedParams.capabilities
Expand All @@ -64,6 +71,7 @@ export default async function CapabilitiesApi (this: That, params?: T.TODO, opti
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
}
}
Expand All @@ -73,6 +81,12 @@ export default async function CapabilitiesApi (this: That, params?: T.TODO, opti
const meta: TransportRequestMetadata = {
name: 'capabilities',
acceptedParams: [
'method',
'path',
'parameters',
'capabilities',
'local_only',
'timeout'
]
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
Expand Down
95 changes: 63 additions & 32 deletions src/api/api/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ export default class Connector {
},
'connector.secret_post': {
path: [],
body: [],
body: [
'value'
],
query: []
},
'connector.secret_put': {
path: [
'id'
],
body: [],
body: [
'value'
],
query: []
},
'connector.sync_job_cancel': {
Expand Down Expand Up @@ -769,12 +773,12 @@ export default class Connector {
}

/**
* Deletes a connector secret
* Deletes a connector secret.
*/
async secretDelete (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async secretDelete (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async secretDelete (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async secretDelete (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async secretDelete (this: That, params: T.ConnectorSecretDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ConnectorSecretDeleteResponse>
async secretDelete (this: That, params: T.ConnectorSecretDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ConnectorSecretDeleteResponse, unknown>>
async secretDelete (this: That, params: T.ConnectorSecretDeleteRequest, options?: TransportRequestOptions): Promise<T.ConnectorSecretDeleteResponse>
async secretDelete (this: That, params: T.ConnectorSecretDeleteRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = this[kAcceptedParams]['connector.secret_delete']
Expand All @@ -792,11 +796,11 @@ export default class Connector {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
}
}
Expand All @@ -816,12 +820,12 @@ export default class Connector {
}

/**
* Retrieves a secret stored by Connectors
* Retrieves a secret stored by Connectors.
*/
async secretGet (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async secretGet (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async secretGet (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async secretGet (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async secretGet (this: That, params: T.ConnectorSecretGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ConnectorSecretGetResponse>
async secretGet (this: That, params: T.ConnectorSecretGetRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ConnectorSecretGetResponse, unknown>>
async secretGet (this: That, params: T.ConnectorSecretGetRequest, options?: TransportRequestOptions): Promise<T.ConnectorSecretGetResponse>
async secretGet (this: That, params: T.ConnectorSecretGetRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = this[kAcceptedParams]['connector.secret_get']
Expand All @@ -839,11 +843,11 @@ export default class Connector {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
}
}
Expand All @@ -863,14 +867,16 @@ export default class Connector {
}

/**
* Creates a secret for a Connector
* Creates a secret for a Connector.
*/
async secretPost (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async secretPost (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async secretPost (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async secretPost (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async secretPost (this: That, params?: T.ConnectorSecretPostRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ConnectorSecretPostResponse>
async secretPost (this: That, params?: T.ConnectorSecretPostRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ConnectorSecretPostResponse, unknown>>
async secretPost (this: That, params?: T.ConnectorSecretPostRequest, options?: TransportRequestOptions): Promise<T.ConnectorSecretPostResponse>
async secretPost (this: That, params?: T.ConnectorSecretPostRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this[kAcceptedParams]['connector.secret_post']

const userQuery = params?.querystring
Expand All @@ -888,10 +894,21 @@ export default class Connector {

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
if (acceptedBody.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

Expand All @@ -900,20 +917,23 @@ export default class Connector {
const meta: TransportRequestMetadata = {
name: 'connector.secret_post',
acceptedParams: [
'value'
]
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
}

/**
* Creates or updates a secret for a Connector
* Creates or updates a secret for a Connector.
*/
async secretPut (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async secretPut (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async secretPut (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async secretPut (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async secretPut (this: That, params: T.ConnectorSecretPutRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ConnectorSecretPutResponse>
async secretPut (this: That, params: T.ConnectorSecretPutRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ConnectorSecretPutResponse, unknown>>
async secretPut (this: That, params: T.ConnectorSecretPutRequest, options?: TransportRequestOptions): Promise<T.ConnectorSecretPutResponse>
async secretPut (this: That, params: T.ConnectorSecretPutRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this[kAcceptedParams]['connector.secret_put']

const userQuery = params?.querystring
Expand All @@ -929,12 +949,22 @@ export default class Connector {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
if (acceptedBody.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

Expand All @@ -946,7 +976,8 @@ export default class Connector {
id: params.id
},
acceptedParams: [
'id'
'id',
'value'
]
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
Expand Down
59 changes: 37 additions & 22 deletions src/api/api/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default class Fleet {
},
'fleet.post_secret': {
path: [],
body: [],
body: [
'value'
],
query: []
},
'fleet.search': {
Expand Down Expand Up @@ -178,12 +180,12 @@ export default class Fleet {
}

/**
* Deletes a secret stored by Fleet
* Deletes a secret stored by Fleet.
*/
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async deleteSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async deleteSecret (this: That, params: T.FleetDeleteSecretRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetDeleteSecretResponse>
async deleteSecret (this: That, params: T.FleetDeleteSecretRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetDeleteSecretResponse, unknown>>
async deleteSecret (this: That, params: T.FleetDeleteSecretRequest, options?: TransportRequestOptions): Promise<T.FleetDeleteSecretResponse>
async deleteSecret (this: That, params: T.FleetDeleteSecretRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = this[kAcceptedParams]['fleet.delete_secret']
Expand All @@ -201,11 +203,11 @@ export default class Fleet {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
}
}
Expand All @@ -225,12 +227,12 @@ export default class Fleet {
}

/**
* Retrieves a secret stored by Fleet
* Retrieves a secret stored by Fleet.
*/
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async getSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async getSecret (this: That, params: T.FleetGetSecretRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetGetSecretResponse>
async getSecret (this: That, params: T.FleetGetSecretRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetGetSecretResponse, unknown>>
async getSecret (this: That, params: T.FleetGetSecretRequest, options?: TransportRequestOptions): Promise<T.FleetGetSecretResponse>
async getSecret (this: That, params: T.FleetGetSecretRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
} = this[kAcceptedParams]['fleet.get_secret']
Expand All @@ -248,11 +250,11 @@ export default class Fleet {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
// @ts-expect-error
querystring[key] = params[key]
}
}
Expand Down Expand Up @@ -395,14 +397,16 @@ export default class Fleet {
}

/**
* Creates a secret stored by Fleet
* Creates a secret stored by Fleet.
*/
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
async postSecret (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
async postSecret (this: That, params: T.FleetPostSecretRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetPostSecretResponse>
async postSecret (this: That, params: T.FleetPostSecretRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetPostSecretResponse, unknown>>
async postSecret (this: That, params: T.FleetPostSecretRequest, options?: TransportRequestOptions): Promise<T.FleetPostSecretResponse>
async postSecret (this: That, params: T.FleetPostSecretRequest, options?: TransportRequestOptions): Promise<any> {
const {
path: acceptedPath
path: acceptedPath,
body: acceptedBody,
query: acceptedQuery
} = this[kAcceptedParams]['fleet.post_secret']

const userQuery = params?.querystring
Expand All @@ -418,12 +422,22 @@ export default class Fleet {
}
}

params = params ?? {}
for (const key in params) {
if (acceptedPath.includes(key)) {
if (acceptedBody.includes(key)) {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
} else if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body' && key !== 'querystring') {
querystring[key] = params[key]
if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) {
// @ts-expect-error
querystring[key] = params[key]
} else {
body = body ?? {}
// @ts-expect-error
body[key] = params[key]
}
}
}

Expand All @@ -432,6 +446,7 @@ export default class Fleet {
const meta: TransportRequestMetadata = {
name: 'fleet.post_secret',
acceptedParams: [
'value'
]
}
return await this.transport.request({ path, method, querystring, body, meta }, options)
Expand Down
Loading