|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +module Elasticsearch |
| 19 | + module XPack |
| 20 | + module API |
| 21 | + module Security |
| 22 | + module Actions |
| 23 | + |
| 24 | + # Creates an API key for access without requiring basic authentication. |
| 25 | + # |
| 26 | + # @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make |
| 27 | + # this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to |
| 28 | + # search, if `false` then do nothing with refreshes. |
| 29 | + # |
| 30 | + # @option arguments [Hash] :body The api key request to create an API key. (*Required*) |
| 31 | + # |
| 32 | + # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html |
| 33 | + # |
| 34 | + def create_api_key(arguments={}) |
| 35 | + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] |
| 36 | + |
| 37 | + valid_params = [ :refresh ] |
| 38 | + |
| 39 | + method = Elasticsearch::API::HTTP_PUT |
| 40 | + path = "_security/api_key" |
| 41 | + params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, valid_params |
| 42 | + |
| 43 | + perform_request(method, path, params, arguments[:body]).body |
| 44 | + end |
| 45 | + end |
| 46 | + end |
| 47 | + end |
| 48 | + end |
| 49 | +end |
0 commit comments