Skip to content

Commit

Permalink
API generation
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed May 31, 2021
1 parent fe6a73b commit afa2161
Show file tree
Hide file tree
Showing 9 changed files with 630 additions and 27 deletions.
65 changes: 65 additions & 0 deletions api/api/fleet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

'use strict'

/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
const acceptedQuerystring = ['wait_for_advance', 'wait_for_index', 'checkpoints', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
const snakeCase = { waitForAdvance: 'wait_for_advance', waitForIndex: 'wait_for_index', errorTrace: 'error_trace', filterPath: 'filter_path' }

function FleetApi (transport, ConfigurationError) {
this.transport = transport
this[kConfigurationError] = ConfigurationError
}

FleetApi.prototype.globalCheckpoints = function fleetGlobalCheckpointsApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required parameters
if (params.index == null) {
const err = new this[kConfigurationError]('Missing required parameter: index')
return handleError(err, callback)
}

let { method, body, index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if (method == null) method = 'GET'
path = '/' + encodeURIComponent(index) + '/' + '_fleet' + '/' + 'global_checkpoints'

// build request object
const request = {
method,
path,
body: null,
querystring
}

return this.transport.request(request, options, callback)
}

Object.defineProperties(FleetApi.prototype, {
global_checkpoints: { get () { return this.globalCheckpoints } }
})

module.exports = FleetApi
2 changes: 1 addition & 1 deletion api/api/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MonitoringApi.prototype.bulk = function monitoringBulkApi (params, options, call
const request = {
method,
path,
body: body || '',
bulkBody: body,
querystring
}

Expand Down
31 changes: 29 additions & 2 deletions api/api/searchable_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,40 @@
/* eslint no-unused-vars: 0 */

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
const acceptedQuerystring = ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'index', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'master_timeout', 'wait_for_completion', 'storage', 'level']
const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForCompletion: 'wait_for_completion' }
const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'index', 'master_timeout', 'wait_for_completion', 'storage', 'level']
const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', masterTimeout: 'master_timeout', waitForCompletion: 'wait_for_completion' }

function SearchableSnapshotsApi (transport, ConfigurationError) {
this.transport = transport
this[kConfigurationError] = ConfigurationError
}

SearchableSnapshotsApi.prototype.cacheStats = function searchableSnapshotsCacheStatsApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

let { method, body, nodeId, node_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if ((node_id || nodeId) != null) {
if (method == null) method = 'GET'
path = '/' + '_searchable_snapshots' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'cache' + '/' + 'stats'
} else {
if (method == null) method = 'GET'
path = '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'stats'
}

// build request object
const request = {
method,
path,
body: null,
querystring
}

return this.transport.request(request, options, callback)
}

SearchableSnapshotsApi.prototype.clearCache = function searchableSnapshotsClearCacheApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

Expand Down Expand Up @@ -152,6 +178,7 @@ SearchableSnapshotsApi.prototype.stats = function searchableSnapshotsStatsApi (p
}

Object.defineProperties(SearchableSnapshotsApi.prototype, {
cache_stats: { get () { return this.cacheStats } },
clear_cache: { get () { return this.clearCache } },
repository_stats: { get () { return this.repositoryStats } }
})
Expand Down
210 changes: 210 additions & 0 deletions api/api/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,50 @@ SecurityApi.prototype.clearCachedRoles = function securityClearCachedRolesApi (p
return this.transport.request(request, options, callback)
}

SecurityApi.prototype.clearCachedServiceTokens = function securityClearCachedServiceTokensApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required parameters
if (params.namespace == null) {
const err = new this[kConfigurationError]('Missing required parameter: namespace')
return handleError(err, callback)
}
if (params.service == null) {
const err = new this[kConfigurationError]('Missing required parameter: service')
return handleError(err, callback)
}
if (params.name == null) {
const err = new this[kConfigurationError]('Missing required parameter: name')
return handleError(err, callback)
}

// check required url components
if (params.name != null && (params.service == null || params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: service, namespace')
return handleError(err, callback)
} else if (params.service != null && (params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: namespace')
return handleError(err, callback)
}

let { method, body, namespace, service, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if (method == null) method = 'POST'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service) + '/' + 'credential' + '/' + 'token' + '/' + encodeURIComponent(name) + '/' + '_clear_cache'

// build request object
const request = {
method,
path,
body: body || '',
querystring
}

return this.transport.request(request, options, callback)
}

SecurityApi.prototype.createApiKey = function securityCreateApiKeyApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

Expand Down Expand Up @@ -219,6 +263,51 @@ SecurityApi.prototype.createApiKey = function securityCreateApiKeyApi (params, o
return this.transport.request(request, options, callback)
}

SecurityApi.prototype.createServiceToken = function securityCreateServiceTokenApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required parameters
if (params.namespace == null) {
const err = new this[kConfigurationError]('Missing required parameter: namespace')
return handleError(err, callback)
}
if (params.service == null) {
const err = new this[kConfigurationError]('Missing required parameter: service')
return handleError(err, callback)
}

// check required url components
if (params.name != null && (params.service == null || params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: service, namespace')
return handleError(err, callback)
} else if (params.service != null && (params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: namespace')
return handleError(err, callback)
}

let { method, body, namespace, service, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if ((namespace) != null && (service) != null && (name) != null) {
if (method == null) method = 'PUT'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service) + '/' + 'credential' + '/' + 'token' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'POST'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service) + '/' + 'credential' + '/' + 'token'
}

// build request object
const request = {
method,
path,
body: body || '',
querystring
}

return this.transport.request(request, options, callback)
}

SecurityApi.prototype.deletePrivileges = function securityDeletePrivilegesApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

Expand Down Expand Up @@ -310,6 +399,50 @@ SecurityApi.prototype.deleteRoleMapping = function securityDeleteRoleMappingApi
return this.transport.request(request, options, callback)
}

SecurityApi.prototype.deleteServiceToken = function securityDeleteServiceTokenApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required parameters
if (params.namespace == null) {
const err = new this[kConfigurationError]('Missing required parameter: namespace')
return handleError(err, callback)
}
if (params.service == null) {
const err = new this[kConfigurationError]('Missing required parameter: service')
return handleError(err, callback)
}
if (params.name == null) {
const err = new this[kConfigurationError]('Missing required parameter: name')
return handleError(err, callback)
}

// check required url components
if (params.name != null && (params.service == null || params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: service, namespace')
return handleError(err, callback)
} else if (params.service != null && (params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: namespace')
return handleError(err, callback)
}

let { method, body, namespace, service, name, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if (method == null) method = 'DELETE'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service) + '/' + 'credential' + '/' + 'token' + '/' + encodeURIComponent(name)

// build request object
const request = {
method,
path,
body: body || '',
querystring
}

return this.transport.request(request, options, callback)
}

SecurityApi.prototype.deleteUser = function securityDeleteUserApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

Expand Down Expand Up @@ -520,6 +653,78 @@ SecurityApi.prototype.getRoleMapping = function securityGetRoleMappingApi (param
return this.transport.request(request, options, callback)
}

SecurityApi.prototype.getServiceAccounts = function securityGetServiceAccountsApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required url components
if (params.service != null && (params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: namespace')
return handleError(err, callback)
}

let { method, body, namespace, service, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if ((namespace) != null && (service) != null) {
if (method == null) method = 'GET'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service)
} else if ((namespace) != null) {
if (method == null) method = 'GET'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace)
} else {
if (method == null) method = 'GET'
path = '/' + '_security' + '/' + 'service'
}

// build request object
const request = {
method,
path,
body: null,
querystring
}

return this.transport.request(request, options, callback)
}

SecurityApi.prototype.getServiceCredentials = function securityGetServiceCredentialsApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

// check required parameters
if (params.namespace == null) {
const err = new this[kConfigurationError]('Missing required parameter: namespace')
return handleError(err, callback)
}
if (params.service == null) {
const err = new this[kConfigurationError]('Missing required parameter: service')
return handleError(err, callback)
}

// check required url components
if (params.service != null && (params.namespace == null)) {
const err = new this[kConfigurationError]('Missing required parameter of the url: namespace')
return handleError(err, callback)
}

let { method, body, namespace, service, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)

let path = ''
if (method == null) method = 'GET'
path = '/' + '_security' + '/' + 'service' + '/' + encodeURIComponent(namespace) + '/' + encodeURIComponent(service) + '/' + 'credential'

// build request object
const request = {
method,
path,
body: null,
querystring
}

return this.transport.request(request, options, callback)
}

SecurityApi.prototype.getToken = function securityGetTokenApi (params, options, callback) {
;[params, options, callback] = normalizeArguments(params, options, callback)

Expand Down Expand Up @@ -833,10 +1038,13 @@ Object.defineProperties(SecurityApi.prototype, {
clear_cached_privileges: { get () { return this.clearCachedPrivileges } },
clear_cached_realms: { get () { return this.clearCachedRealms } },
clear_cached_roles: { get () { return this.clearCachedRoles } },
clear_cached_service_tokens: { get () { return this.clearCachedServiceTokens } },
create_api_key: { get () { return this.createApiKey } },
create_service_token: { get () { return this.createServiceToken } },
delete_privileges: { get () { return this.deletePrivileges } },
delete_role: { get () { return this.deleteRole } },
delete_role_mapping: { get () { return this.deleteRoleMapping } },
delete_service_token: { get () { return this.deleteServiceToken } },
delete_user: { get () { return this.deleteUser } },
disable_user: { get () { return this.disableUser } },
enable_user: { get () { return this.enableUser } },
Expand All @@ -845,6 +1053,8 @@ Object.defineProperties(SecurityApi.prototype, {
get_privileges: { get () { return this.getPrivileges } },
get_role: { get () { return this.getRole } },
get_role_mapping: { get () { return this.getRoleMapping } },
get_service_accounts: { get () { return this.getServiceAccounts } },
get_service_credentials: { get () { return this.getServiceCredentials } },
get_token: { get () { return this.getToken } },
get_user: { get () { return this.getUser } },
get_user_privileges: { get () { return this.getUserPrivileges } },
Expand Down
4 changes: 2 additions & 2 deletions api/api/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/* eslint no-unused-vars: 0 */

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion', 'verify', 'ignore_unavailable', 'verbose', 'local']
const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion', ignoreUnavailable: 'ignore_unavailable' }
const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion', 'verify', 'ignore_unavailable', 'index_details', 'verbose', 'local']
const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion', ignoreUnavailable: 'ignore_unavailable', indexDetails: 'index_details' }

function SnapshotApi (transport, ConfigurationError) {
this.transport = transport
Expand Down
Loading

0 comments on commit afa2161

Please sign in to comment.