# coding: utf-8

"""
    Kestra EE

    All API operations, except for Superadmin-only endpoints, require a tenant identifier in the HTTP path.<br/> Endpoints designated as Superadmin-only are not tenant-scoped.

    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501
# Custom imports
import requests
import sseclient
import json
from typing import Generator


import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictInt, StrictStr
from typing import List, Optional
from typing_extensions import Annotated
from kestrapy.models.kv_controller_api_delete_bulk_request import KVControllerApiDeleteBulkRequest
from kestrapy.models.kv_controller_api_delete_bulk_response import KVControllerApiDeleteBulkResponse
from kestrapy.models.kv_controller_typed_value import KVControllerTypedValue
from kestrapy.models.kv_entry import KVEntry
from kestrapy.models.paged_results_kv_entry import PagedResultsKVEntry
from kestrapy.models.query_filter import QueryFilter

from kestrapy.api_client import ApiClient, RequestSerialized
from kestrapy.api_response import ApiResponse
from kestrapy.rest import RESTResponseType


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

    @validate_call
    def delete_key_value(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> bool:
        """Delete a key-value pair


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._delete_key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "bool",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_key_value_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[bool]:
        """Delete a key-value pair


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._delete_key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "bool",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _delete_key_value_serialize(
        self,
        namespace,
        key,
        tenant,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if key is not None:
            _path_params['key'] = key
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv/{key}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def delete_key_values(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        kv_controller_api_delete_bulk_request: Annotated[KVControllerApiDeleteBulkRequest, Field(description="The keys")],
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> KVControllerApiDeleteBulkResponse:
        """Bulk-delete multiple key/value pairs from the given namespace.


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
                :param kv_controller_api_delete_bulk_request: The keys (required)
        :type kv_controller_api_delete_bulk_request: KVControllerApiDeleteBulkRequest
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._delete_key_values_serialize(
            namespace=namespace,
            tenant=tenant,
            kv_controller_api_delete_bulk_request=kv_controller_api_delete_bulk_request,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "KVControllerApiDeleteBulkResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def delete_key_values_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        kv_controller_api_delete_bulk_request: Annotated[KVControllerApiDeleteBulkRequest, Field(description="The keys")],
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[KVControllerApiDeleteBulkResponse]:
        """Bulk-delete multiple key/value pairs from the given namespace.


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
                :param kv_controller_api_delete_bulk_request: The keys (required)
        :type kv_controller_api_delete_bulk_request: KVControllerApiDeleteBulkRequest
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._delete_key_values_serialize(
            namespace=namespace,
            tenant=tenant,
            kv_controller_api_delete_bulk_request=kv_controller_api_delete_bulk_request,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "KVControllerApiDeleteBulkResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _delete_key_values_serialize(
        self,
        namespace,
        tenant,
        kv_controller_api_delete_bulk_request,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if kv_controller_api_delete_bulk_request is not None:
            _body_params = kv_controller_api_delete_bulk_request



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )

        # set the HTTP header `Content-Type`

        _default_content_type = (
            self.api_client.select_header_content_type(
                [
                    'application/json'
                ]
            )
        )
        if _default_content_type is not None:
            _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='DELETE',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def key_value(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> KVControllerTypedValue:
        """Get value for a key


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "KVControllerTypedValue",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def key_value_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[KVControllerTypedValue]:
        """Get value for a key


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "KVControllerTypedValue",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _key_value_serialize(
        self,
        namespace,
        key,
        tenant,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if key is not None:
            _path_params['key'] = key
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv/{key}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def list_all_keys(
        self,
        page: Annotated[StrictInt, Field(description="The current page")],
        size: Annotated[StrictInt, Field(description="The current page size")],
        tenant: StrictStr,
        sort: Annotated[Optional[List[StrictStr]], Field(description="The sort of current page")] = None,
        filters: Annotated[Optional[List[QueryFilter]], Field(description="Filters")] = None,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> PagedResultsKVEntry:
        """List all keys


        :param page: The current page (required)
        :type page: int
                :param size: The current page size (required)
        :type size: int
                :param tenant: (required)
        :type tenant: str
                :param sort: The sort of current page
        :type sort: List[str]
                :param filters: Filters
        :type filters: List[QueryFilter]
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._list_all_keys_serialize(
            page=page,
            size=size,
            tenant=tenant,
            sort=sort,
            filters=filters,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "PagedResultsKVEntry",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def list_all_keys_with_http_info(
        self,
        page: Annotated[StrictInt, Field(description="The current page")],
        size: Annotated[StrictInt, Field(description="The current page size")],
        tenant: StrictStr,
        sort: Annotated[Optional[List[StrictStr]], Field(description="The sort of current page")] = None,
        filters: Annotated[Optional[List[QueryFilter]], Field(description="Filters")] = None,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[PagedResultsKVEntry]:
        """List all keys


        :param page: The current page (required)
        :type page: int
                :param size: The current page size (required)
        :type size: int
                :param tenant: (required)
        :type tenant: str
                :param sort: The sort of current page
        :type sort: List[str]
                :param filters: Filters
        :type filters: List[QueryFilter]
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._list_all_keys_serialize(
            page=page,
            size=size,
            tenant=tenant,
            sort=sort,
            filters=filters,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "PagedResultsKVEntry",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _list_all_keys_serialize(
        self,
        page,
        size,
        tenant,
        sort,
        filters,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
            'sort': 'csv',
            'filters': 'csv',
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        if page is not None:
            
            _query_params.append(('page', page))
            
        if size is not None:
            
            _query_params.append(('size', size))
            
        if sort is not None:
            
            _query_params.append(('sort', sort))
            
        if filters is not None:
            
            _query_params.append(('filters', filters))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/api/v1/{tenant}/kv',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def list_keys(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> List[KVEntry]:
        """(Deprecated) List all keys for a namespace


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501
        warnings.warn("GET /api/v1/{tenant}/namespaces/{namespace}/kv is deprecated.", DeprecationWarning)

        _param = self._list_keys_serialize(
            namespace=namespace,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "List[KVEntry]",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def list_keys_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[List[KVEntry]]:
        """(Deprecated) List all keys for a namespace


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501
        warnings.warn("GET /api/v1/{tenant}/namespaces/{namespace}/kv is deprecated.", DeprecationWarning)

        _param = self._list_keys_serialize(
            namespace=namespace,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "List[KVEntry]",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _list_keys_serialize(
        self,
        namespace,
        tenant,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def list_keys_with_inheritence(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> List[KVEntry]:
        """List all keys for inherited namespaces


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._list_keys_with_inheritence_serialize(
            namespace=namespace,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "List[KVEntry]",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def list_keys_with_inheritence_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        tenant: StrictStr,
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[List[KVEntry]]:
        """List all keys for inherited namespaces


        :param namespace: The namespace id (required)
        :type namespace: str
                :param tenant: (required)
        :type tenant: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._list_keys_with_inheritence_serialize(
            namespace=namespace,
            tenant=tenant,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "List[KVEntry]",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _list_keys_with_inheritence_serialize(
        self,
        namespace,
        tenant,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter



        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv/inheritance',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )





    @validate_call
    def set_key_value(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        body: Annotated[StrictStr, Field(description="The value of the key")],
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> None:
        """Puts a key-value pair in store


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
                :param body: The value of the key (required)
        :type body: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._set_key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
            body=body,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': None,
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def set_key_value_with_http_info(
        self,
        namespace: Annotated[StrictStr, Field(description="The namespace id")],
        key: Annotated[StrictStr, Field(description="The key")],
        tenant: StrictStr,
        body: Annotated[StrictStr, Field(description="The value of the key")],
        _request_timeout: Union[
        None,
        Annotated[StrictFloat, Field(gt=0)],
        Tuple[
        Annotated[StrictFloat, Field(gt=0)],
        Annotated[StrictFloat, Field(gt=0)]
        ]
        ] = None
    ) -> ApiResponse[None]:
        """Puts a key-value pair in store


        :param namespace: The namespace id (required)
        :type namespace: str
                :param key: The key (required)
        :type key: str
                :param tenant: (required)
        :type tenant: str
                :param body: The value of the key (required)
        :type body: str
        ,
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        """ # noqa: E501

        _param = self._set_key_value_serialize(
            namespace=namespace,
            key=key,
            tenant=tenant,
            body=body,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': None,
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    def _set_key_value_serialize(
        self,
        namespace,
        key,
        tenant,
        body,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if namespace is not None:
            _path_params['namespace'] = namespace
        if key is not None:
            _path_params['key'] = key
        if tenant is not None:
            _path_params['tenant'] = tenant
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter
        if body is not None:
            _body_params = body




        # set the HTTP header `Content-Type`

        _default_content_type = (
            self.api_client.select_header_content_type(
                [
                    'text/plain'
                ]
            )
        )
        if _default_content_type is not None:
            _header_params['Content-Type'] = _default_content_type

        # authentication setting
        _auth_settings: List[str] = [
            'basicAuth', 
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='PUT',
            resource_path='/api/v1/{tenant}/namespaces/{namespace}/kv/{key}',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats
        )




