# coding: utf-8

"""
    ThingsBoard REST API

     ThingsBoard Professional Edition IoT platform REST API documentation.  # noqa: E501

    OpenAPI spec version: 3.7.0PE
    Contact: info@thingsboard.io
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

#  Copyright 2024. ThingsBoard
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from tb_rest_client.api_client import ApiClient


class TwoFactorAuthConfigControllerApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def delete_two_fa_account_config_using_delete(self, provider_type, **kwargs):  # noqa: E501
        """Delete 2FA account config (deleteTwoFaAccountConfig)  # noqa: E501

        Delete 2FA config for a given 2FA provider type.  Returns whole account's 2FA settings object.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_two_fa_account_config_using_delete(provider_type, async_req=True)
        >>> result = thread.get()

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

    def delete_two_fa_account_config_using_delete_with_http_info(self, provider_type, **kwargs):  # noqa: E501
        """Delete 2FA account config (deleteTwoFaAccountConfig)  # noqa: E501

        Delete 2FA config for a given 2FA provider type.  Returns whole account's 2FA settings object.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_two_fa_account_config_using_delete_with_http_info(provider_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str provider_type: providerType (required)
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'provider_type' in params:
            query_params.append(('providerType', params['provider_type']))  # 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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/config{?providerType}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AccountTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def generate_two_fa_account_config_using_post(self, provider_type, **kwargs):  # noqa: E501
        """Generate 2FA account config (generateTwoFaAccountConfig)  # noqa: E501

        Generate new 2FA account config template for specified provider type.   For TOTP, this will return a corresponding account config template with a generated OTP auth URL (with new random secret key for each API call) that can be then converted to a QR code to scan with an authenticator app. Example: ``` {   \"providerType\": \"TOTP\",   \"useByDefault\": false,   \"authUrl\": \"otpauth://totp/TB%202FA:tenant@thingsboard.org?issuer=TB+2FA&secret=PNJDNWJVAK4ZTUYT7RFGPQLXA7XGU7PX\" } ```  For EMAIL, the generated config will contain email from user's account: ``` {   \"providerType\": \"EMAIL\",   \"useByDefault\": false,   \"email\": \"tenant@thingsboard.org\" } ```  For SMS 2FA this method will just return a config with empty/default values as there is nothing to generate/preset: ``` {   \"providerType\": \"SMS\",   \"useByDefault\": false,   \"phoneNumber\": null } ```  Will throw an error (Bad Request) if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_two_fa_account_config_using_post(provider_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str provider_type: 2FA provider type to generate new account config for (required)
        :return: TwoFaAccountConfig
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.generate_two_fa_account_config_using_post_with_http_info(provider_type, **kwargs)  # noqa: E501
        else:
            (data) = self.generate_two_fa_account_config_using_post_with_http_info(provider_type, **kwargs)  # noqa: E501
            return data

    def generate_two_fa_account_config_using_post_with_http_info(self, provider_type, **kwargs):  # noqa: E501
        """Generate 2FA account config (generateTwoFaAccountConfig)  # noqa: E501

        Generate new 2FA account config template for specified provider type.   For TOTP, this will return a corresponding account config template with a generated OTP auth URL (with new random secret key for each API call) that can be then converted to a QR code to scan with an authenticator app. Example: ``` {   \"providerType\": \"TOTP\",   \"useByDefault\": false,   \"authUrl\": \"otpauth://totp/TB%202FA:tenant@thingsboard.org?issuer=TB+2FA&secret=PNJDNWJVAK4ZTUYT7RFGPQLXA7XGU7PX\" } ```  For EMAIL, the generated config will contain email from user's account: ``` {   \"providerType\": \"EMAIL\",   \"useByDefault\": false,   \"email\": \"tenant@thingsboard.org\" } ```  For SMS 2FA this method will just return a config with empty/default values as there is nothing to generate/preset: ``` {   \"providerType\": \"SMS\",   \"useByDefault\": false,   \"phoneNumber\": null } ```  Will throw an error (Bad Request) if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_two_fa_account_config_using_post_with_http_info(provider_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str provider_type: 2FA provider type to generate new account config for (required)
        :return: TwoFaAccountConfig
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'provider_type' in params:
            query_params.append(('providerType', params['provider_type']))  # 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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/config/generate{?providerType}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TwoFaAccountConfig',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_account_two_fa_settings_using_get(self, **kwargs):  # noqa: E501
        """Get account 2FA settings (getAccountTwoFaSettings)  # noqa: E501

        Get user's account 2FA configuration. Configuration contains configs for different 2FA providers.  Example: ``` {   \"configs\": {     \"EMAIL\": {       \"providerType\": \"EMAIL\",       \"useByDefault\": true,       \"email\": \"tenant@thingsboard.org\"     },     \"TOTP\": {       \"providerType\": \"TOTP\",       \"useByDefault\": false,       \"authUrl\": \"otpauth://totp/TB%202FA:tenant@thingsboard.org?issuer=TB+2FA&secret=P6Z2TLYTASOGP6LCJZAD24ETT5DACNNX\"     },     \"SMS\": {       \"providerType\": \"SMS\",       \"useByDefault\": false,       \"phoneNumber\": \"+380501253652\"     }   } } ```  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_account_two_fa_settings_using_get(async_req=True)
        >>> result = thread.get()

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

    def get_account_two_fa_settings_using_get_with_http_info(self, **kwargs):  # noqa: E501
        """Get account 2FA settings (getAccountTwoFaSettings)  # noqa: E501

        Get user's account 2FA configuration. Configuration contains configs for different 2FA providers.  Example: ``` {   \"configs\": {     \"EMAIL\": {       \"providerType\": \"EMAIL\",       \"useByDefault\": true,       \"email\": \"tenant@thingsboard.org\"     },     \"TOTP\": {       \"providerType\": \"TOTP\",       \"useByDefault\": false,       \"authUrl\": \"otpauth://totp/TB%202FA:tenant@thingsboard.org?issuer=TB+2FA&secret=P6Z2TLYTASOGP6LCJZAD24ETT5DACNNX\"     },     \"SMS\": {       \"providerType\": \"SMS\",       \"useByDefault\": false,       \"phoneNumber\": \"+380501253652\"     }   } } ```  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_account_two_fa_settings_using_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_account_two_fa_settings_using_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/settings', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AccountTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_available_two_fa_providers_using_get(self, **kwargs):  # noqa: E501
        """Get available 2FA providers (getAvailableTwoFaProviders)  # noqa: E501

        Get the list of provider types available for user to use (the ones configured by tenant or sysadmin). Example of response: ``` [   \"TOTP\",   \"EMAIL\",   \"SMS\" ] ```  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_available_two_fa_providers_using_get(async_req=True)
        >>> result = thread.get()

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

    def get_available_two_fa_providers_using_get_with_http_info(self, **kwargs):  # noqa: E501
        """Get available 2FA providers (getAvailableTwoFaProviders)  # noqa: E501

        Get the list of provider types available for user to use (the ones configured by tenant or sysadmin). Example of response: ``` [   \"TOTP\",   \"EMAIL\",   \"SMS\" ] ```  Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_available_two_fa_providers_using_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: list[str]
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_available_two_fa_providers_using_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/providers', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[str]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_platform_two_fa_settings_using_get(self, **kwargs):  # noqa: E501
        """Get platform 2FA settings (getPlatformTwoFaSettings)  # noqa: E501

        Get platform settings for 2FA. The settings are described for savePlatformTwoFaSettings API method. If 2FA is not configured, then an empty response will be returned.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_platform_two_fa_settings_using_get(async_req=True)
        >>> result = thread.get()

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

    def get_platform_two_fa_settings_using_get_with_http_info(self, **kwargs):  # noqa: E501
        """Get platform 2FA settings (getPlatformTwoFaSettings)  # noqa: E501

        Get platform settings for 2FA. The settings are described for savePlatformTwoFaSettings API method. If 2FA is not configured, then an empty response will be returned.  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_platform_two_fa_settings_using_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: PlatformTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_platform_two_fa_settings_using_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/settings', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='PlatformTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def save_platform_two_fa_settings_using_post(self, **kwargs):  # noqa: E501
        """Save platform 2FA settings (savePlatformTwoFaSettings)  # noqa: E501

        Save 2FA settings for platform. The settings have following properties: - `useSystemTwoFactorAuthSettings` - option for tenant admins to use 2FA settings configured by sysadmin. If this param is set to true, then the settings will not be validated for constraints (if it is a tenant admin; for sysadmin this param is ignored). - `providers` - the list of 2FA providers' configs. Users will only be allowed to use 2FA providers from this list.   - `minVerificationCodeSendPeriod` - minimal period in seconds to wait after verification code send request to send next request.  - `verificationCodeCheckRateLimit` - rate limit configuration for verification code checking. The format is standard: 'amountOfRequests:periodInSeconds'. The value of '1:60' would limit verification code checking requests to one per minute. - `maxVerificationFailuresBeforeUserLockout` - maximum number of verification failures before a user gets disabled. - `totalAllowedTimeForVerification` - total amount of time in seconds allotted for verification. Basically, this property sets a lifetime for pre-verification token. If not set, default value of 30 minutes is used.   TOTP 2FA provider config has following settings: - `issuerName` - issuer name that will be displayed in an authenticator app near a username. Must not be blank.  For SMS 2FA provider: - `smsVerificationMessageTemplate` - verification message template.  Available template variables are ${code} and ${userEmail}. It must not be blank and must contain verification code variable. - `verificationCodeLifetime` - verification code lifetime in seconds. Required to be positive.  For EMAIL provider type: - `verificationCodeLifetime` - the same as for SMS.  Example of the settings: ``` {   \"useSystemTwoFactorAuthSettings\": false,   \"providers\": [     {       \"providerType\": \"TOTP\",       \"issuerName\": \"TB\"     },     {       \"providerType\": \"EMAIL\",       \"verificationCodeLifetime\": 60     },     {       \"providerType\": \"SMS\",       \"verificationCodeLifetime\": 60,       \"smsVerificationMessageTemplate\": \"Here is your verification code: ${code}\"     }   ],   \"minVerificationCodeSendPeriod\": 60,   \"verificationCodeCheckRateLimit\": \"3:900\",   \"maxVerificationFailuresBeforeUserLockout\": 10,   \"totalAllowedTimeForVerification\": 600 } ```  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.save_platform_two_fa_settings_using_post(async_req=True)
        >>> result = thread.get()

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

    def save_platform_two_fa_settings_using_post_with_http_info(self, **kwargs):  # noqa: E501
        """Save platform 2FA settings (savePlatformTwoFaSettings)  # noqa: E501

        Save 2FA settings for platform. The settings have following properties: - `useSystemTwoFactorAuthSettings` - option for tenant admins to use 2FA settings configured by sysadmin. If this param is set to true, then the settings will not be validated for constraints (if it is a tenant admin; for sysadmin this param is ignored). - `providers` - the list of 2FA providers' configs. Users will only be allowed to use 2FA providers from this list.   - `minVerificationCodeSendPeriod` - minimal period in seconds to wait after verification code send request to send next request.  - `verificationCodeCheckRateLimit` - rate limit configuration for verification code checking. The format is standard: 'amountOfRequests:periodInSeconds'. The value of '1:60' would limit verification code checking requests to one per minute. - `maxVerificationFailuresBeforeUserLockout` - maximum number of verification failures before a user gets disabled. - `totalAllowedTimeForVerification` - total amount of time in seconds allotted for verification. Basically, this property sets a lifetime for pre-verification token. If not set, default value of 30 minutes is used.   TOTP 2FA provider config has following settings: - `issuerName` - issuer name that will be displayed in an authenticator app near a username. Must not be blank.  For SMS 2FA provider: - `smsVerificationMessageTemplate` - verification message template.  Available template variables are ${code} and ${userEmail}. It must not be blank and must contain verification code variable. - `verificationCodeLifetime` - verification code lifetime in seconds. Required to be positive.  For EMAIL provider type: - `verificationCodeLifetime` - the same as for SMS.  Example of the settings: ``` {   \"useSystemTwoFactorAuthSettings\": false,   \"providers\": [     {       \"providerType\": \"TOTP\",       \"issuerName\": \"TB\"     },     {       \"providerType\": \"EMAIL\",       \"verificationCodeLifetime\": 60     },     {       \"providerType\": \"SMS\",       \"verificationCodeLifetime\": 60,       \"smsVerificationMessageTemplate\": \"Here is your verification code: ${code}\"     }   ],   \"minVerificationCodeSendPeriod\": 60,   \"verificationCodeCheckRateLimit\": \"3:900\",   \"maxVerificationFailuresBeforeUserLockout\": 10,   \"totalAllowedTimeForVerification\": 600 } ```  Available for users with 'SYS_ADMIN' or 'TENANT_ADMIN' authority.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.save_platform_two_fa_settings_using_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param PlatformTwoFaSettings body:
        :return: PlatformTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method save_platform_two_fa_settings_using_post" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # 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

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/settings', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='PlatformTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def submit_two_fa_account_config_using_post(self, **kwargs):  # noqa: E501
        """Submit 2FA account config (submitTwoFaAccountConfig)  # noqa: E501

        Submit 2FA account config to prepare for a future verification. Basically, this method will send a verification code for a given account config, if this has sense for a chosen 2FA provider. This code is needed to then verify and save the account config.  Example of EMAIL 2FA account config: ``` {   \"providerType\": \"EMAIL\",   \"useByDefault\": true,   \"email\": \"separate-email-for-2fa@thingsboard.org\" } ```  Example of SMS 2FA account config: ``` {   \"providerType\": \"SMS\",   \"useByDefault\": false,   \"phoneNumber\": \"+38012312321\" } ```  For TOTP this method does nothing.  Will throw an error (Bad Request) if submitted account config is not valid, or if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.submit_two_fa_account_config_using_post(async_req=True)
        >>> result = thread.get()

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

    def submit_two_fa_account_config_using_post_with_http_info(self, **kwargs):  # noqa: E501
        """Submit 2FA account config (submitTwoFaAccountConfig)  # noqa: E501

        Submit 2FA account config to prepare for a future verification. Basically, this method will send a verification code for a given account config, if this has sense for a chosen 2FA provider. This code is needed to then verify and save the account config.  Example of EMAIL 2FA account config: ``` {   \"providerType\": \"EMAIL\",   \"useByDefault\": true,   \"email\": \"separate-email-for-2fa@thingsboard.org\" } ```  Example of SMS 2FA account config: ``` {   \"providerType\": \"SMS\",   \"useByDefault\": false,   \"phoneNumber\": \"+38012312321\" } ```  For TOTP this method does nothing.  Will throw an error (Bad Request) if submitted account config is not valid, or if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.submit_two_fa_account_config_using_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TwoFaAccountConfig body:
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method submit_two_fa_account_config_using_post" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # 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

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/config/submit', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def update_two_fa_account_config_using_put(self, provider_type, **kwargs):  # noqa: E501
        """Update 2FA account config (updateTwoFaAccountConfig)  # noqa: E501

        Update config for a given provider type.  Update request example: ``` {   \"useByDefault\": true } ``` Returns whole account's 2FA settings object.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_two_fa_account_config_using_put(provider_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str provider_type: providerType (required)
        :param TwoFaAccountConfigUpdateRequest body:
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_two_fa_account_config_using_put_with_http_info(provider_type, **kwargs)  # noqa: E501
        else:
            (data) = self.update_two_fa_account_config_using_put_with_http_info(provider_type, **kwargs)  # noqa: E501
            return data

    def update_two_fa_account_config_using_put_with_http_info(self, provider_type, **kwargs):  # noqa: E501
        """Update 2FA account config (updateTwoFaAccountConfig)  # noqa: E501

        Update config for a given provider type.  Update request example: ``` {   \"useByDefault\": true } ``` Returns whole account's 2FA settings object.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_two_fa_account_config_using_put_with_http_info(provider_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str provider_type: providerType (required)
        :param TwoFaAccountConfigUpdateRequest body:
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'provider_type' in params:
            query_params.append(('providerType', params['provider_type']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # 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

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/config{?providerType}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AccountTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def verify_and_save_two_fa_account_config_using_post(self, **kwargs):  # noqa: E501
        """Verify and save 2FA account config (verifyAndSaveTwoFaAccountConfig)  # noqa: E501

        Checks the verification code for submitted config, and if it is correct, saves the provided account config.   Returns whole account's 2FA settings object. Will throw an error (Bad Request) if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.verify_and_save_two_fa_account_config_using_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TwoFaAccountConfig body:
        :param str verification_code: verificationCode
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.verify_and_save_two_fa_account_config_using_post_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.verify_and_save_two_fa_account_config_using_post_with_http_info(**kwargs)  # noqa: E501
            return data

    def verify_and_save_two_fa_account_config_using_post_with_http_info(self, **kwargs):  # noqa: E501
        """Verify and save 2FA account config (verifyAndSaveTwoFaAccountConfig)  # noqa: E501

        Checks the verification code for submitted config, and if it is correct, saves the provided account config.   Returns whole account's 2FA settings object. Will throw an error (Bad Request) if the provider is not configured for usage.   Available for any authorized user.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.verify_and_save_two_fa_account_config_using_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param TwoFaAccountConfig body:
        :param str verification_code: verificationCode
        :return: AccountTwoFaSettings
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'verification_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')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method verify_and_save_two_fa_account_config_using_post" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'verification_code' in params:
            query_params.append(('verificationCode', params['verification_code']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # 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

        # Authentication setting
        auth_settings = ['X-Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/api/2fa/account/config{?verificationCode}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AccountTwoFaSettings',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
