Source code for sdkms.v1.apis.authentication_api

# coding: utf-8

"""
    Fortanix DSM REST API

    This is a set of REST APIs for accessing the Fortanix Data Security Manager. This includes APIs for managing accounts, and for performing cryptographic and key management operations. 

    OpenAPI spec version: 1.0.0-20200608
    Contact: support@fortanix.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git

    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 sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


# 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
[docs]class AuthenticationApi(object):
[docs] def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client
[docs] def authorize(self, async_call=False, **kwargs): """ Authenticate a user or an app to SDKMS to begin a session. The caller needs to provide a basic authentication token to authenticate to SDKMS. The response body contains a bearer authentication token which needs to be provided by subsequent calls for the duration of the session. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `AuthResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.authorize_with_http_info(async_call=async_call, **kwargs) else: (data) = self.authorize_with_http_info(async_call=async_call, **kwargs) return data
def authorize_with_http_info(self, async_call=False, **kwargs): """ Authenticate a user or an app to SDKMS to begin a session. The caller needs to provide a basic authentication token to authenticate to SDKMS. The response body contains a bearer authentication token which needs to be provided by subsequent calls for the duration of the session. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.authorize_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `AuthResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method authorize" % 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']) # Authentication setting auth_settings = ['basicAuth'] return self.api_client.call_api('/sys/v1/session/auth', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='AuthResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def check_health(self, async_call=False, **kwargs): """ Returns a 200-class status code if the server is handling requests, or a 500-class status code if the server is having problems. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.check_health_with_http_info(async_call=async_call, **kwargs) else: (data) = self.check_health_with_http_info(async_call=async_call, **kwargs) return data
def check_health_with_http_info(self, async_call=False, **kwargs): """ Returns a 200-class status code if the server is handling requests, or a 500-class status code if the server is having problems. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.check_health_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method check_health" % 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']) # Authentication setting auth_settings = [] return self.api_client.call_api('/sys/v1/health', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def get_server_version(self, async_call=False, **kwargs): """ Returns information about the SDKMS server version and the client API version that it supports. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `VersionResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.get_server_version_with_http_info(async_call=async_call, **kwargs) else: (data) = self.get_server_version_with_http_info(async_call=async_call, **kwargs) return data
def get_server_version_with_http_info(self, async_call=False, **kwargs): """ Returns information about the SDKMS server version and the client API version that it supports. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.get_server_version_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `VersionResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method get_server_version" % 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']) # Authentication setting auth_settings = [] return self.api_client.call_api('/sys/v1/version', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='VersionResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def re_auth(self, async_call=False, **kwargs): """ Authenticate a user or an app to SDKMS using existing session token, to generate a new session. The caller needs to provide bearer authentication token of an existing valid session. The response body contains a bearer authentication token of the new session created. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `AuthResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.re_auth_with_http_info(async_call=async_call, **kwargs) else: (data) = self.re_auth_with_http_info(async_call=async_call, **kwargs) return data
def re_auth_with_http_info(self, async_call=False, **kwargs): """ Authenticate a user or an app to SDKMS using existing session token, to generate a new session. The caller needs to provide bearer authentication token of an existing valid session. The response body contains a bearer authentication token of the new session created. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.re_auth_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: `AuthResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method re_auth" % 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']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/reauth', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='AuthResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def refresh(self, async_call=False, **kwargs): """ Refreshes an existing session, thus extending the expiration time of the existing bearer authentication token. The caller needs to provide bearer token of sesssion need to be refreshed. The response body is empty. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.refresh_with_http_info(async_call=async_call, **kwargs) else: (data) = self.refresh_with_http_info(async_call=async_call, **kwargs) return data
def refresh_with_http_info(self, async_call=False, **kwargs): """ Refreshes an existing session, thus extending the expiration time of the existing bearer authentication token. The caller needs to provide bearer token of sesssion need to be refreshed. The response body is empty. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.refresh_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method refresh" % 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']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/refresh', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def select_account(self, body, async_call=False, **kwargs): """ Select one of user's account to proceed. This is applicable when a user is associated with more than one account. The caller needs to provide a bearer token for the session in the request body. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `SelectAccountRequest` :param body: Select Account Request (required) :rtype: `SelectAccountResponse` :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.select_account_with_http_info(body, async_call=async_call, **kwargs) else: (data) = self.select_account_with_http_info(body, async_call=async_call, **kwargs) return data
def select_account_with_http_info(self, body, async_call=False, **kwargs): """ Select one of user's account to proceed. This is applicable when a user is associated with more than one account. The caller needs to provide a bearer token for the session in the request body. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.select_account_with_http_info(body, async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :type body: `SelectAccountRequest` :param body: Select Account Request (required) :rtype: `SelectAccountResponse` :return: If the method is called asynchronously, returns the request thread. """ all_params = ['body'] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method select_account" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params) or (params['body'] is None): raise ValueError("Missing the required parameter `body` when calling `select_account`") 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']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/select_account', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='SelectAccountResponse', auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def terminate(self, async_call=False, **kwargs): """ Terminate an authenticated session. After this call, the provided bearer authentication token will be invalidated and cannot be used to make any further API calls. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.terminate_with_http_info(async_call=async_call, **kwargs) else: (data) = self.terminate_with_http_info(async_call=async_call, **kwargs) return data
def terminate_with_http_info(self, async_call=False, **kwargs): """ Terminate an authenticated session. After this call, the provided bearer authentication token will be invalidated and cannot be used to make any further API calls. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.terminate_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method terminate" % 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']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/terminate', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _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)
[docs] def unlock2_f(self, async_call=False, **kwargs): """ Re-authenticate to unlock two factor configuration. Two factor configuration must be unlocked to enable or disable two factor authentication, add or remove two factor devices, or regenerate recovery codes. The caller needs to provide a bearer token for the session in the request body. :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if async_call: return self.unlock2_f_with_http_info(async_call=async_call, **kwargs) else: (data) = self.unlock2_f_with_http_info(async_call=async_call, **kwargs) return data
def unlock2_f_with_http_info(self, async_call=False, **kwargs): """ Re-authenticate to unlock two factor configuration. Two factor configuration must be unlocked to enable or disable two factor authentication, add or remove two factor devices, or regenerate recovery codes. The caller needs to provide a bearer token for the session in the request body. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_call=True:: >>> thread = api.unlock2_f_with_http_info(async_call=True) >>> result = thread.get() :type async_call: bool :param async_call: Whether the call should be performed asynchronously. (Default is False). :rtype: None :return: If the method is called asynchronously, returns the request thread. """ all_params = [] all_params.append('async_call') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') params = locals() for key, val in iteritems(params['kwargs']): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" " to method unlock2_f" % 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']) # Authentication setting auth_settings = ['bearerToken'] return self.api_client.call_api('/sys/v1/session/config_2fa/auth', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, auth_settings=auth_settings, async_call=params.get('async_call'), _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)