/* * 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. */ /* eslint-disable import/export */ /* eslint-disable @typescript-eslint/no-misused-new */ /* eslint-disable @typescript-eslint/no-extraneous-class */ /* eslint-disable @typescript-eslint/no-unused-vars */ // This file was automatically generated by elastic/elastic-client-generator-js // DO NOT MODIFY IT BY HAND. Instead, modify the source open api file, // and elastic/elastic-client-generator-js to regenerate this file again. import { Transport, TransportRequestMetadata, TransportRequestOptions, TransportRequestOptionsWithMeta, TransportRequestOptionsWithOutMeta, TransportResult } from '@elastic/transport' import * as T from '../types' import * as TB from '../typesWithBodyKey' interface That { transport: Transport } export default class Snapshot { transport: Transport constructor (transport: Transport) { this.transport = transport } /** * Removes stale data from repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/clean-up-snapshot-repo-api.html | Elasticsearch API documentation} */ async cleanupRepository (this: That, params: T.SnapshotCleanupRepositoryRequest | TB.SnapshotCleanupRepositoryRequest, options?: TransportRequestOptionsWithOutMeta): Promise async cleanupRepository (this: That, params: T.SnapshotCleanupRepositoryRequest | TB.SnapshotCleanupRepositoryRequest, options?: TransportRequestOptionsWithMeta): Promise> async cleanupRepository (this: That, params: T.SnapshotCleanupRepositoryRequest | TB.SnapshotCleanupRepositoryRequest, options?: TransportRequestOptions): Promise async cleanupRepository (this: That, params: T.SnapshotCleanupRepositoryRequest | TB.SnapshotCleanupRepositoryRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['name'] const querystring: Record = {} const body = undefined for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'POST' const path = `/_snapshot/${encodeURIComponent(params.name.toString())}/_cleanup` const meta: TransportRequestMetadata = { name: 'snapshot.cleanup_repository', pathParts: { name: params.name } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Clones indices from one snapshot into another snapshot in the same repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async clone (this: That, params: T.SnapshotCloneRequest | TB.SnapshotCloneRequest, options?: TransportRequestOptionsWithOutMeta): Promise async clone (this: That, params: T.SnapshotCloneRequest | TB.SnapshotCloneRequest, options?: TransportRequestOptionsWithMeta): Promise> async clone (this: That, params: T.SnapshotCloneRequest | TB.SnapshotCloneRequest, options?: TransportRequestOptions): Promise async clone (this: That, params: T.SnapshotCloneRequest | TB.SnapshotCloneRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot', 'target_snapshot'] const acceptedBody: string[] = ['indices'] const querystring: Record = {} // @ts-expect-error const userBody: any = params?.body let body: Record | string if (typeof userBody === 'string') { body = userBody } else { body = userBody != null ? { ...userBody } : undefined } for (const key in params) { if (acceptedBody.includes(key)) { body = body ?? {} // @ts-expect-error body[key] = params[key] } else if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'PUT' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}/_clone/${encodeURIComponent(params.target_snapshot.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.clone', pathParts: { repository: params.repository, snapshot: params.snapshot, target_snapshot: params.target_snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Creates a snapshot in a repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async create (this: That, params: T.SnapshotCreateRequest | TB.SnapshotCreateRequest, options?: TransportRequestOptionsWithOutMeta): Promise async create (this: That, params: T.SnapshotCreateRequest | TB.SnapshotCreateRequest, options?: TransportRequestOptionsWithMeta): Promise> async create (this: That, params: T.SnapshotCreateRequest | TB.SnapshotCreateRequest, options?: TransportRequestOptions): Promise async create (this: That, params: T.SnapshotCreateRequest | TB.SnapshotCreateRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot'] const acceptedBody: string[] = ['ignore_unavailable', 'include_global_state', 'indices', 'feature_states', 'metadata', 'partial'] const querystring: Record = {} // @ts-expect-error const userBody: any = params?.body let body: Record | string if (typeof userBody === 'string') { body = userBody } else { body = userBody != null ? { ...userBody } : undefined } for (const key in params) { if (acceptedBody.includes(key)) { body = body ?? {} // @ts-expect-error body[key] = params[key] } else if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'PUT' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.create', pathParts: { repository: params.repository, snapshot: params.snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Creates a repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async createRepository (this: That, params: T.SnapshotCreateRepositoryRequest | TB.SnapshotCreateRepositoryRequest, options?: TransportRequestOptionsWithOutMeta): Promise async createRepository (this: That, params: T.SnapshotCreateRepositoryRequest | TB.SnapshotCreateRepositoryRequest, options?: TransportRequestOptionsWithMeta): Promise> async createRepository (this: That, params: T.SnapshotCreateRepositoryRequest | TB.SnapshotCreateRepositoryRequest, options?: TransportRequestOptions): Promise async createRepository (this: That, params: T.SnapshotCreateRepositoryRequest | TB.SnapshotCreateRepositoryRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['name'] const acceptedBody: string[] = ['repository'] const querystring: Record = {} // @ts-expect-error let body: any = params.body ?? undefined for (const key in params) { if (acceptedBody.includes(key)) { // @ts-expect-error body = params[key] } else if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'PUT' const path = `/_snapshot/${encodeURIComponent(params.name.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.create_repository', pathParts: { name: params.name } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Deletes one or more snapshots. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async delete (this: That, params: T.SnapshotDeleteRequest | TB.SnapshotDeleteRequest, options?: TransportRequestOptionsWithOutMeta): Promise async delete (this: That, params: T.SnapshotDeleteRequest | TB.SnapshotDeleteRequest, options?: TransportRequestOptionsWithMeta): Promise> async delete (this: That, params: T.SnapshotDeleteRequest | TB.SnapshotDeleteRequest, options?: TransportRequestOptions): Promise async delete (this: That, params: T.SnapshotDeleteRequest | TB.SnapshotDeleteRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot'] const querystring: Record = {} const body = undefined for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'DELETE' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.delete', pathParts: { repository: params.repository, snapshot: params.snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Deletes a repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async deleteRepository (this: That, params: T.SnapshotDeleteRepositoryRequest | TB.SnapshotDeleteRepositoryRequest, options?: TransportRequestOptionsWithOutMeta): Promise async deleteRepository (this: That, params: T.SnapshotDeleteRepositoryRequest | TB.SnapshotDeleteRepositoryRequest, options?: TransportRequestOptionsWithMeta): Promise> async deleteRepository (this: That, params: T.SnapshotDeleteRepositoryRequest | TB.SnapshotDeleteRepositoryRequest, options?: TransportRequestOptions): Promise async deleteRepository (this: That, params: T.SnapshotDeleteRepositoryRequest | TB.SnapshotDeleteRepositoryRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['name'] const querystring: Record = {} const body = undefined for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'DELETE' const path = `/_snapshot/${encodeURIComponent(params.name.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.delete_repository', pathParts: { name: params.name } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Returns information about a snapshot. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async get (this: That, params: T.SnapshotGetRequest | TB.SnapshotGetRequest, options?: TransportRequestOptionsWithOutMeta): Promise async get (this: That, params: T.SnapshotGetRequest | TB.SnapshotGetRequest, options?: TransportRequestOptionsWithMeta): Promise> async get (this: That, params: T.SnapshotGetRequest | TB.SnapshotGetRequest, options?: TransportRequestOptions): Promise async get (this: That, params: T.SnapshotGetRequest | TB.SnapshotGetRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot'] const querystring: Record = {} const body = undefined for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'GET' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}` const meta: TransportRequestMetadata = { name: 'snapshot.get', pathParts: { repository: params.repository, snapshot: params.snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Returns information about a repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async getRepository (this: That, params?: T.SnapshotGetRepositoryRequest | TB.SnapshotGetRepositoryRequest, options?: TransportRequestOptionsWithOutMeta): Promise async getRepository (this: That, params?: T.SnapshotGetRepositoryRequest | TB.SnapshotGetRepositoryRequest, options?: TransportRequestOptionsWithMeta): Promise> async getRepository (this: That, params?: T.SnapshotGetRepositoryRequest | TB.SnapshotGetRepositoryRequest, options?: TransportRequestOptions): Promise async getRepository (this: That, params?: T.SnapshotGetRepositoryRequest | TB.SnapshotGetRepositoryRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['name'] const querystring: Record = {} const body = undefined params = params ?? {} for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } let method = '' let path = '' if (params.name != null) { method = 'GET' path = `/_snapshot/${encodeURIComponent(params.name.toString())}` } else { method = 'GET' path = '/_snapshot' } const meta: TransportRequestMetadata = { name: 'snapshot.get_repository', pathParts: { name: params.name } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Analyzes a repository for correctness and performance * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async repositoryAnalyze (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise async repositoryAnalyze (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise> async repositoryAnalyze (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise async repositoryAnalyze (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository'] const querystring: Record = {} const body = undefined params = params ?? {} for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { querystring[key] = params[key] } } const method = 'POST' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/_analyze` const meta: TransportRequestMetadata = { name: 'snapshot.repository_analyze', pathParts: { repository: params.repository } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Restores a snapshot. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async restore (this: That, params: T.SnapshotRestoreRequest | TB.SnapshotRestoreRequest, options?: TransportRequestOptionsWithOutMeta): Promise async restore (this: That, params: T.SnapshotRestoreRequest | TB.SnapshotRestoreRequest, options?: TransportRequestOptionsWithMeta): Promise> async restore (this: That, params: T.SnapshotRestoreRequest | TB.SnapshotRestoreRequest, options?: TransportRequestOptions): Promise async restore (this: That, params: T.SnapshotRestoreRequest | TB.SnapshotRestoreRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot'] const acceptedBody: string[] = ['feature_states', 'ignore_index_settings', 'ignore_unavailable', 'include_aliases', 'include_global_state', 'index_settings', 'indices', 'partial', 'rename_pattern', 'rename_replacement'] const querystring: Record = {} // @ts-expect-error const userBody: any = params?.body let body: Record | string if (typeof userBody === 'string') { body = userBody } else { body = userBody != null ? { ...userBody } : undefined } for (const key in params) { if (acceptedBody.includes(key)) { body = body ?? {} // @ts-expect-error body[key] = params[key] } else if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'POST' const path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}/_restore` const meta: TransportRequestMetadata = { name: 'snapshot.restore', pathParts: { repository: params.repository, snapshot: params.snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Returns information about the status of a snapshot. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async status (this: That, params?: T.SnapshotStatusRequest | TB.SnapshotStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise async status (this: That, params?: T.SnapshotStatusRequest | TB.SnapshotStatusRequest, options?: TransportRequestOptionsWithMeta): Promise> async status (this: That, params?: T.SnapshotStatusRequest | TB.SnapshotStatusRequest, options?: TransportRequestOptions): Promise async status (this: That, params?: T.SnapshotStatusRequest | TB.SnapshotStatusRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['repository', 'snapshot'] const querystring: Record = {} const body = undefined params = params ?? {} for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } let method = '' let path = '' if (params.repository != null && params.snapshot != null) { method = 'GET' path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/${encodeURIComponent(params.snapshot.toString())}/_status` } else if (params.repository != null) { method = 'GET' path = `/_snapshot/${encodeURIComponent(params.repository.toString())}/_status` } else { method = 'GET' path = '/_snapshot/_status' } const meta: TransportRequestMetadata = { name: 'snapshot.status', pathParts: { repository: params.repository, snapshot: params.snapshot } } return await this.transport.request({ path, method, querystring, body, meta }, options) } /** * Verifies a repository. * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.14/modules-snapshots.html | Elasticsearch API documentation} */ async verifyRepository (this: That, params: T.SnapshotVerifyRepositoryRequest | TB.SnapshotVerifyRepositoryRequest, options?: TransportRequestOptionsWithOutMeta): Promise async verifyRepository (this: That, params: T.SnapshotVerifyRepositoryRequest | TB.SnapshotVerifyRepositoryRequest, options?: TransportRequestOptionsWithMeta): Promise> async verifyRepository (this: That, params: T.SnapshotVerifyRepositoryRequest | TB.SnapshotVerifyRepositoryRequest, options?: TransportRequestOptions): Promise async verifyRepository (this: That, params: T.SnapshotVerifyRepositoryRequest | TB.SnapshotVerifyRepositoryRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['name'] const querystring: Record = {} const body = undefined for (const key in params) { if (acceptedPath.includes(key)) { continue } else if (key !== 'body') { // @ts-expect-error querystring[key] = params[key] } } const method = 'POST' const path = `/_snapshot/${encodeURIComponent(params.name.toString())}/_verify` const meta: TransportRequestMetadata = { name: 'snapshot.verify_repository', pathParts: { name: params.name } } return await this.transport.request({ path, method, querystring, body, meta }, options) } }