# coding: utf-8

"""
    herd

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

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


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from herdsdk.api_client import ApiClient


class TagApi(object):
    """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):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def tag_create_tag(self, tag_create_request, **kwargs):  # noqa: E501
        """createTag  # noqa: E501

        Creates a new tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_create_tag(tag_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TagCreateRequest tag_create_request: the information needed to create the tag (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_create_tag_with_http_info(tag_create_request, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_create_tag_with_http_info(tag_create_request, **kwargs)  # noqa: E501
            return data

    def tag_create_tag_with_http_info(self, tag_create_request, **kwargs):  # noqa: E501
        """createTag  # noqa: E501

        Creates a new tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_create_tag_with_http_info(tag_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TagCreateRequest tag_create_request: the information needed to create the tag (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_create_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_create_tag" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_create_request' is set
        if ('tag_create_request' not in local_var_params or
                local_var_params['tag_create_request'] is None):
            raise ValueError("Missing the required parameter `tag_create_request` when calling `tag_create_tag`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Tag',  # noqa: E501
            auth_settings=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=collection_formats)

    def tag_delete_tag(self, tag_type_code, tag_code, **kwargs):  # noqa: E501
        """deleteTag  # noqa: E501

        Deletes an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_delete_tag(tag_type_code, tag_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_delete_tag_with_http_info(tag_type_code, tag_code, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_delete_tag_with_http_info(tag_type_code, tag_code, **kwargs)  # noqa: E501
            return data

    def tag_delete_tag_with_http_info(self, tag_type_code, tag_code, **kwargs):  # noqa: E501
        """deleteTag  # noqa: E501

        Deletes an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_delete_tag_with_http_info(tag_type_code, tag_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_type_code', 'tag_code']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_delete_tag" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_type_code' is set
        if ('tag_type_code' not in local_var_params or
                local_var_params['tag_type_code'] is None):
            raise ValueError("Missing the required parameter `tag_type_code` when calling `tag_delete_tag`")  # noqa: E501
        # verify the required parameter 'tag_code' is set
        if ('tag_code' not in local_var_params or
                local_var_params['tag_code'] is None):
            raise ValueError("Missing the required parameter `tag_code` when calling `tag_delete_tag`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'tag_type_code' in local_var_params:
            path_params['tagTypeCode'] = local_var_params['tag_type_code']  # noqa: E501
        if 'tag_code' in local_var_params:
            path_params['tagCode'] = local_var_params['tag_code']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags/tagTypes/{tagTypeCode}/tagCodes/{tagCode}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Tag',  # noqa: E501
            auth_settings=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=collection_formats)

    def tag_get_tag(self, tag_type_code, tag_code, **kwargs):  # noqa: E501
        """getTag  # noqa: E501

        Gets an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_get_tag(tag_type_code, tag_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_get_tag_with_http_info(tag_type_code, tag_code, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_get_tag_with_http_info(tag_type_code, tag_code, **kwargs)  # noqa: E501
            return data

    def tag_get_tag_with_http_info(self, tag_type_code, tag_code, **kwargs):  # noqa: E501
        """getTag  # noqa: E501

        Gets an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_get_tag_with_http_info(tag_type_code, tag_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_type_code', 'tag_code']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_get_tag" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_type_code' is set
        if ('tag_type_code' not in local_var_params or
                local_var_params['tag_type_code'] is None):
            raise ValueError("Missing the required parameter `tag_type_code` when calling `tag_get_tag`")  # noqa: E501
        # verify the required parameter 'tag_code' is set
        if ('tag_code' not in local_var_params or
                local_var_params['tag_code'] is None):
            raise ValueError("Missing the required parameter `tag_code` when calling `tag_get_tag`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'tag_type_code' in local_var_params:
            path_params['tagTypeCode'] = local_var_params['tag_type_code']  # noqa: E501
        if 'tag_code' in local_var_params:
            path_params['tagCode'] = local_var_params['tag_code']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags/tagTypes/{tagTypeCode}/tagCodes/{tagCode}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Tag',  # noqa: E501
            auth_settings=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=collection_formats)

    def tag_get_tags(self, tag_type_code, **kwargs):  # noqa: E501
        """getTags  # noqa: E501

        Retrieves all associated tags for the specified tag type code. When tagCode is null, return all tags of the tag type code, which has no parent (i.e. root tags). When tagCode is provided, return all tags of the tag type code and whose parent tag code is tagCode.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_get_tags(tag_type_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type's code. (required)
        :param str tag_code: the parent tag code.
        :return: TagListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_get_tags_with_http_info(tag_type_code, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_get_tags_with_http_info(tag_type_code, **kwargs)  # noqa: E501
            return data

    def tag_get_tags_with_http_info(self, tag_type_code, **kwargs):  # noqa: E501
        """getTags  # noqa: E501

        Retrieves all associated tags for the specified tag type code. When tagCode is null, return all tags of the tag type code, which has no parent (i.e. root tags). When tagCode is provided, return all tags of the tag type code and whose parent tag code is tagCode.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_get_tags_with_http_info(tag_type_code, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type's code. (required)
        :param str tag_code: the parent tag code.
        :return: TagListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_type_code', 'tag_code']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_get_tags" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_type_code' is set
        if ('tag_type_code' not in local_var_params or
                local_var_params['tag_type_code'] is None):
            raise ValueError("Missing the required parameter `tag_type_code` when calling `tag_get_tags`")  # noqa: E501

        collection_formats = {}

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

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

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags/tagTypes/{tagTypeCode}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TagListResponse',  # noqa: E501
            auth_settings=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=collection_formats)

    def tag_search_tags(self, tag_search_request, **kwargs):  # noqa: E501
        """searchTags  # noqa: E501

        Retrieves all tags existing in the system per specified search filters and keys. For each tag entity, this endpoint returns tag key by default along with any other top-level elements as specified by the \"fields\" query string parameter. The list of tags returned by this endpoint is sorted alphabetically by tag's display name ascending.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_search_tags(tag_search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TagSearchRequest tag_search_request: the tag search request. The request can only accept a single search filter and a single search key (required)
        :param str fields: the field options for the tag type search response. The valid field options are: displayName, description, parentTagKey, hasChildren
        :return: TagSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_search_tags_with_http_info(tag_search_request, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_search_tags_with_http_info(tag_search_request, **kwargs)  # noqa: E501
            return data

    def tag_search_tags_with_http_info(self, tag_search_request, **kwargs):  # noqa: E501
        """searchTags  # noqa: E501

        Retrieves all tags existing in the system per specified search filters and keys. For each tag entity, this endpoint returns tag key by default along with any other top-level elements as specified by the \"fields\" query string parameter. The list of tags returned by this endpoint is sorted alphabetically by tag's display name ascending.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_search_tags_with_http_info(tag_search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TagSearchRequest tag_search_request: the tag search request. The request can only accept a single search filter and a single search key (required)
        :param str fields: the field options for the tag type search response. The valid field options are: displayName, description, parentTagKey, hasChildren
        :return: TagSearchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_search_request', 'fields']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_search_tags" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_search_request' is set
        if ('tag_search_request' not in local_var_params or
                local_var_params['tag_search_request'] is None):
            raise ValueError("Missing the required parameter `tag_search_request` when calling `tag_search_tags`")  # noqa: E501

        collection_formats = {}

        path_params = {}

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

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags/search', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TagSearchResponse',  # noqa: E501
            auth_settings=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=collection_formats)

    def tag_update_tag(self, tag_type_code, tag_code, tag_update_request, **kwargs):  # noqa: E501
        """updateTag  # noqa: E501

        Updates an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_update_tag(tag_type_code, tag_code, tag_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :param TagUpdateRequest tag_update_request: the information needed to update the tag (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.tag_update_tag_with_http_info(tag_type_code, tag_code, tag_update_request, **kwargs)  # noqa: E501
        else:
            (data) = self.tag_update_tag_with_http_info(tag_type_code, tag_code, tag_update_request, **kwargs)  # noqa: E501
            return data

    def tag_update_tag_with_http_info(self, tag_type_code, tag_code, tag_update_request, **kwargs):  # noqa: E501
        """updateTag  # noqa: E501

        Updates an existing tag.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tag_update_tag_with_http_info(tag_type_code, tag_code, tag_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str tag_type_code: the tag type code (required)
        :param str tag_code: the tag code (required)
        :param TagUpdateRequest tag_update_request: the information needed to update the tag (required)
        :return: Tag
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['tag_type_code', 'tag_code', 'tag_update_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tag_update_tag" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'tag_type_code' is set
        if ('tag_type_code' not in local_var_params or
                local_var_params['tag_type_code'] is None):
            raise ValueError("Missing the required parameter `tag_type_code` when calling `tag_update_tag`")  # noqa: E501
        # verify the required parameter 'tag_code' is set
        if ('tag_code' not in local_var_params or
                local_var_params['tag_code'] is None):
            raise ValueError("Missing the required parameter `tag_code` when calling `tag_update_tag`")  # noqa: E501
        # verify the required parameter 'tag_update_request' is set
        if ('tag_update_request' not in local_var_params or
                local_var_params['tag_update_request'] is None):
            raise ValueError("Missing the required parameter `tag_update_request` when calling `tag_update_tag`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'tag_type_code' in local_var_params:
            path_params['tagTypeCode'] = local_var_params['tag_type_code']  # noqa: E501
        if 'tag_code' in local_var_params:
            path_params['tagCode'] = local_var_params['tag_code']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/tags/tagTypes/{tagTypeCode}/tagCodes/{tagCode}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Tag',  # noqa: E501
            auth_settings=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=collection_formats)
