|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +/* eslint-disable import/export */ |
| 21 | +/* eslint-disable @typescript-eslint/no-misused-new */ |
| 22 | +/* eslint-disable @typescript-eslint/no-extraneous-class */ |
| 23 | +/* eslint-disable @typescript-eslint/no-unused-vars */ |
| 24 | + |
| 25 | +// This file was automatically generated by elastic/elastic-client-generator-js |
| 26 | +// DO NOT MODIFY IT BY HAND. Instead, modify the source open api file, |
| 27 | +// and elastic/elastic-client-generator-js to regenerate this file again. |
| 28 | + |
| 29 | +import { |
| 30 | + Transport, |
| 31 | + TransportRequestOptions, |
| 32 | + TransportRequestOptionsWithMeta, |
| 33 | + TransportRequestOptionsWithOutMeta, |
| 34 | + TransportResult |
| 35 | +} from '@elastic/transport' |
| 36 | +import * as T from '../types' |
| 37 | +import * as TB from '../typesWithBodyKey' |
| 38 | +interface That { transport: Transport } |
| 39 | + |
| 40 | +export default class Synonyms { |
| 41 | + transport: Transport |
| 42 | + constructor (transport: Transport) { |
| 43 | + this.transport = transport |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Deletes a synonym set |
| 48 | + * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.9/delete-synonyms.html Elasticsearch API docs} |
| 49 | + */ |
| 50 | + async delete (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> |
| 51 | + async delete (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> |
| 52 | + async delete (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO> |
| 53 | + async delete (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> { |
| 54 | + const acceptedPath: string[] = ['synonyms_set'] |
| 55 | + const querystring: Record<string, any> = {} |
| 56 | + const body = undefined |
| 57 | + |
| 58 | + params = params ?? {} |
| 59 | + for (const key in params) { |
| 60 | + if (acceptedPath.includes(key)) { |
| 61 | + continue |
| 62 | + } else if (key !== 'body') { |
| 63 | + querystring[key] = params[key] |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + const method = 'DELETE' |
| 68 | + const path = `/_synonyms/${encodeURIComponent(params.synonyms_set.toString())}` |
| 69 | + return await this.transport.request({ path, method, querystring, body }, options) |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Retrieves a synonym set |
| 74 | + * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.9/get-synonyms.html Elasticsearch API docs} |
| 75 | + */ |
| 76 | + async get (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> |
| 77 | + async get (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> |
| 78 | + async get (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO> |
| 79 | + async get (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> { |
| 80 | + const acceptedPath: string[] = ['synonyms_set'] |
| 81 | + const querystring: Record<string, any> = {} |
| 82 | + const body = undefined |
| 83 | + |
| 84 | + params = params ?? {} |
| 85 | + for (const key in params) { |
| 86 | + if (acceptedPath.includes(key)) { |
| 87 | + continue |
| 88 | + } else if (key !== 'body') { |
| 89 | + querystring[key] = params[key] |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + const method = 'GET' |
| 94 | + const path = `/_synonyms/${encodeURIComponent(params.synonyms_set.toString())}` |
| 95 | + return await this.transport.request({ path, method, querystring, body }, options) |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Creates or updates a synonyms set |
| 100 | + * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.9/put-synonyms.html Elasticsearch API docs} |
| 101 | + */ |
| 102 | + async put (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO> |
| 103 | + async put (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>> |
| 104 | + async put (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO> |
| 105 | + async put (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> { |
| 106 | + const acceptedPath: string[] = ['synonyms_set'] |
| 107 | + const querystring: Record<string, any> = {} |
| 108 | + const body = undefined |
| 109 | + |
| 110 | + params = params ?? {} |
| 111 | + for (const key in params) { |
| 112 | + if (acceptedPath.includes(key)) { |
| 113 | + continue |
| 114 | + } else if (key !== 'body') { |
| 115 | + querystring[key] = params[key] |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + const method = 'PUT' |
| 120 | + const path = `/_synonyms/${encodeURIComponent(params.synonyms_set.toString())}` |
| 121 | + return await this.transport.request({ path, method, querystring, body }, options) |
| 122 | + } |
| 123 | +} |
0 commit comments