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
18from ..utils import (
19    NamespacedClient,
20    query_params,
21    _make_path,
22    SKIP_IN_PATH,
23)
24
25
26class MonitoringClient(NamespacedClient):
27    @query_params("interval", "system_api_version", "system_id")
28    def bulk(self, body, doc_type=None, params=None):
29        """
30        `<http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html>`_
31
32        :arg body: The operation definition and data (action-data pairs),
33            separated by newlines
34        :arg doc_type: Default document type for items which don't provide one
35        :arg interval: Collection interval (e.g., '10s' or '10000ms') of the
36            payload
37        :arg system_api_version: API Version of the monitored system
38        :arg system_id: Identifier of the monitored system
39        """
40        if body in SKIP_IN_PATH:
41            raise ValueError("Empty value passed for a required argument 'body'.")
42        return self.transport.perform_request(
43            "POST",
44            _make_path("_xpack", "monitoring", doc_type, "_bulk"),
45            params=params,
46            body=self.client._bulk_body(body),
47        )
48