# coding: utf-8

"""
InfluxDB OSS API Service.

The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint.   # noqa: E501

OpenAPI spec version: 2.0.0
Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

from influxdb_client.service._base_service import _BaseService


class TemplatesService(_BaseService):
    """NOTE: This class is auto generated by OpenAPI Generator.

    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):  # noqa: E501,D401,D403
        """TemplatesService - a operation defined in OpenAPI."""
        if api_client is None:
            raise ValueError("Invalid value for `api_client`, must be defined.")
        self.api_client = api_client

    def apply_template(self, template_apply, **kwargs):  # noqa: E501,D401,D403
        """Apply or dry-run a template.

        Applies or performs a dry-run of template in an organization.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.apply_template(template_apply, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TemplateApply template_apply: (required)
        :return: TemplateSummary
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.apply_template_with_http_info(template_apply, **kwargs)  # noqa: E501
        else:
            (data) = self.apply_template_with_http_info(template_apply, **kwargs)  # noqa: E501
            return data

    def apply_template_with_http_info(self, template_apply, **kwargs):  # noqa: E501,D401,D403
        """Apply or dry-run a template.

        Applies or performs a dry-run of template in an organization.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.apply_template_with_http_info(template_apply, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TemplateApply template_apply: (required)
        :return: TemplateSummary
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._apply_template_prepare(template_apply, **kwargs)

        return self.api_client.call_api(
            '/api/v2/templates/apply', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='TemplateSummary',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def apply_template_async(self, template_apply, **kwargs):  # noqa: E501,D401,D403
        """Apply or dry-run a template.

        Applies or performs a dry-run of template in an organization.
        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param TemplateApply template_apply: (required)
        :return: TemplateSummary
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._apply_template_prepare(template_apply, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/templates/apply', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='TemplateSummary',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _apply_template_prepare(self, template_apply, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['template_apply']  # noqa: E501
        self._check_operation_params('apply_template', all_params, local_var_params)
        # verify the required parameter 'template_apply' is set
        if ('template_apply' not in local_var_params or
                local_var_params['template_apply'] is None):
            raise ValueError("Missing the required parameter `template_apply` when calling `apply_template`")  # noqa: E501

        path_params = {}

        query_params = []

        header_params = {}

        body_params = None
        if 'template_apply' in local_var_params:
            body_params = local_var_params['template_apply']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'application/x-jsonnet', 'text/yml'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def create_stack(self, **kwargs):  # noqa: E501,D401,D403
        """Create a new stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_stack(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param PostStackRequest post_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_stack_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.create_stack_with_http_info(**kwargs)  # noqa: E501
            return data

    def create_stack_with_http_info(self, **kwargs):  # noqa: E501,D401,D403
        """Create a new stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_stack_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param PostStackRequest post_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._create_stack_prepare(**kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def create_stack_async(self, **kwargs):  # noqa: E501,D401,D403
        """Create a new stack.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param PostStackRequest post_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._create_stack_prepare(**kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _create_stack_prepare(self, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['post_stack_request']  # noqa: E501
        self._check_operation_params('create_stack', all_params, local_var_params)

        path_params = {}

        query_params = []

        header_params = {}

        body_params = None
        if 'post_stack_request' in local_var_params:
            body_params = local_var_params['post_stack_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def delete_stack(self, stack_id, org_id, **kwargs):  # noqa: E501,D401,D403
        """Delete a stack and associated resources.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_stack(stack_id, org_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param str org_id: The identifier of the organization. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.delete_stack_with_http_info(stack_id, org_id, **kwargs)  # noqa: E501
        else:
            (data) = self.delete_stack_with_http_info(stack_id, org_id, **kwargs)  # noqa: E501
            return data

    def delete_stack_with_http_info(self, stack_id, org_id, **kwargs):  # noqa: E501,D401,D403
        """Delete a stack and associated resources.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_stack_with_http_info(stack_id, org_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param str org_id: The identifier of the organization. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._delete_stack_prepare(stack_id, org_id, **kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type=None,  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def delete_stack_async(self, stack_id, org_id, **kwargs):  # noqa: E501,D401,D403
        """Delete a stack and associated resources.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param str org_id: The identifier of the organization. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._delete_stack_prepare(stack_id, org_id, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type=None,  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _delete_stack_prepare(self, stack_id, org_id, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['stack_id', 'org_id']  # noqa: E501
        self._check_operation_params('delete_stack', all_params, local_var_params)
        # verify the required parameter 'stack_id' is set
        if ('stack_id' not in local_var_params or
                local_var_params['stack_id'] is None):
            raise ValueError("Missing the required parameter `stack_id` when calling `delete_stack`")  # noqa: E501
        # verify the required parameter 'org_id' is set
        if ('org_id' not in local_var_params or
                local_var_params['org_id'] is None):
            raise ValueError("Missing the required parameter `org_id` when calling `delete_stack`")  # noqa: E501

        path_params = {}
        if 'stack_id' in local_var_params:
            path_params['stack_id'] = local_var_params['stack_id']  # noqa: E501

        query_params = []
        if 'org_id' in local_var_params:
            query_params.append(('orgID', local_var_params['org_id']))  # noqa: E501

        header_params = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def export_template(self, **kwargs):  # noqa: E501,D401,D403
        """Export a new template.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.export_template(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TemplateExportByID template_export_by_id: Export resources as an InfluxDB template.
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.export_template_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.export_template_with_http_info(**kwargs)  # noqa: E501
            return data

    def export_template_with_http_info(self, **kwargs):  # noqa: E501,D401,D403
        """Export a new template.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.export_template_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TemplateExportByID template_export_by_id: Export resources as an InfluxDB template.
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._export_template_prepare(**kwargs)

        return self.api_client.call_api(
            '/api/v2/templates/export', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='list[object]',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def export_template_async(self, **kwargs):  # noqa: E501,D401,D403
        """Export a new template.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param TemplateExportByID template_export_by_id: Export resources as an InfluxDB template.
        :return: list[object]
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._export_template_prepare(**kwargs)

        return await self.api_client.call_api(
            '/api/v2/templates/export', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='list[object]',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _export_template_prepare(self, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['template_export_by_id']  # noqa: E501
        self._check_operation_params('export_template', all_params, local_var_params)

        path_params = {}

        query_params = []

        header_params = {}

        body_params = None
        if 'template_export_by_id' in local_var_params:
            body_params = local_var_params['template_export_by_id']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/x-yaml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def list_stacks(self, org_id, **kwargs):  # noqa: E501,D401,D403
        """List installed templates.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.list_stacks(org_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str org_id: The organization ID of the stacks (required)
        :param str name: A collection of names to filter the list by.
        :param str stack_id: A collection of stackIDs to filter the list by.
        :return: ListStacksResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_stacks_with_http_info(org_id, **kwargs)  # noqa: E501
        else:
            (data) = self.list_stacks_with_http_info(org_id, **kwargs)  # noqa: E501
            return data

    def list_stacks_with_http_info(self, org_id, **kwargs):  # noqa: E501,D401,D403
        """List installed templates.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.list_stacks_with_http_info(org_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str org_id: The organization ID of the stacks (required)
        :param str name: A collection of names to filter the list by.
        :param str stack_id: A collection of stackIDs to filter the list by.
        :return: ListStacksResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._list_stacks_prepare(org_id, **kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='ListStacksResponse',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def list_stacks_async(self, org_id, **kwargs):  # noqa: E501,D401,D403
        """List installed templates.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param str org_id: The organization ID of the stacks (required)
        :param str name: A collection of names to filter the list by.
        :param str stack_id: A collection of stackIDs to filter the list by.
        :return: ListStacksResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._list_stacks_prepare(org_id, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='ListStacksResponse',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _list_stacks_prepare(self, org_id, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['org_id', 'name', 'stack_id']  # noqa: E501
        self._check_operation_params('list_stacks', all_params, local_var_params)
        # verify the required parameter 'org_id' is set
        if ('org_id' not in local_var_params or
                local_var_params['org_id'] is None):
            raise ValueError("Missing the required parameter `org_id` when calling `list_stacks`")  # noqa: E501

        path_params = {}

        query_params = []
        if 'org_id' in local_var_params:
            query_params.append(('orgID', local_var_params['org_id']))  # noqa: E501
        if 'name' in local_var_params:
            query_params.append(('name', local_var_params['name']))  # noqa: E501
        if 'stack_id' in local_var_params:
            query_params.append(('stackID', local_var_params['stack_id']))  # noqa: E501

        header_params = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def read_stack(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Retrieve a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.read_stack(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.read_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
        else:
            (data) = self.read_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
            return data

    def read_stack_with_http_info(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Retrieve a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.read_stack_with_http_info(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._read_stack_prepare(stack_id, **kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def read_stack_async(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Retrieve a stack.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._read_stack_prepare(stack_id, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _read_stack_prepare(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['stack_id']  # noqa: E501
        self._check_operation_params('read_stack', all_params, local_var_params)
        # verify the required parameter 'stack_id' is set
        if ('stack_id' not in local_var_params or
                local_var_params['stack_id'] is None):
            raise ValueError("Missing the required parameter `stack_id` when calling `read_stack`")  # noqa: E501

        path_params = {}
        if 'stack_id' in local_var_params:
            path_params['stack_id'] = local_var_params['stack_id']  # noqa: E501

        query_params = []

        header_params = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def uninstall_stack(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Uninstall a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.uninstall_stack(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.uninstall_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
        else:
            (data) = self.uninstall_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
            return data

    def uninstall_stack_with_http_info(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Uninstall a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.uninstall_stack_with_http_info(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._uninstall_stack_prepare(stack_id, **kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks/{stack_id}/uninstall', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def uninstall_stack_async(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Uninstall a stack.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._uninstall_stack_prepare(stack_id, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks/{stack_id}/uninstall', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _uninstall_stack_prepare(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['stack_id']  # noqa: E501
        self._check_operation_params('uninstall_stack', all_params, local_var_params)
        # verify the required parameter 'stack_id' is set
        if ('stack_id' not in local_var_params or
                local_var_params['stack_id'] is None):
            raise ValueError("Missing the required parameter `stack_id` when calling `uninstall_stack`")  # noqa: E501

        path_params = {}
        if 'stack_id' in local_var_params:
            path_params['stack_id'] = local_var_params['stack_id']  # noqa: E501

        query_params = []

        header_params = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params

    def update_stack(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Update a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_stack(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param PatchStackRequest patch_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_stack_with_http_info(stack_id, **kwargs)  # noqa: E501
            return data

    def update_stack_with_http_info(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Update a stack.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_stack_with_http_info(stack_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param PatchStackRequest patch_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._update_stack_prepare(stack_id, **kwargs)

        return self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    async def update_stack_async(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        """Update a stack.

        This method makes an asynchronous HTTP request.

        :param async_req bool
        :param str stack_id: The identifier of the stack. (required)
        :param PatchStackRequest patch_stack_request:
        :return: Stack
                 If the method is called asynchronously,
                 returns the request thread.
        """  # noqa: E501
        local_var_params, path_params, query_params, header_params, body_params = \
            self._update_stack_prepare(stack_id, **kwargs)

        return await self.api_client.call_api(
            '/api/v2/stacks/{stack_id}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=[],
            files={},
            response_type='Stack',  # noqa: E501
            auth_settings=[],
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats={},
            urlopen_kw=kwargs.get('urlopen_kw', None))

    def _update_stack_prepare(self, stack_id, **kwargs):  # noqa: E501,D401,D403
        local_var_params = locals()

        all_params = ['stack_id', 'patch_stack_request']  # noqa: E501
        self._check_operation_params('update_stack', all_params, local_var_params)
        # verify the required parameter 'stack_id' is set
        if ('stack_id' not in local_var_params or
                local_var_params['stack_id'] is None):
            raise ValueError("Missing the required parameter `stack_id` when calling `update_stack`")  # noqa: E501

        path_params = {}
        if 'stack_id' in local_var_params:
            path_params['stack_id'] = local_var_params['stack_id']  # noqa: E501

        query_params = []

        header_params = {}

        body_params = None
        if 'patch_stack_request' in local_var_params:
            body_params = local_var_params['patch_stack_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        return local_var_params, path_params, query_params, header_params, body_params
