# 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 AppsApi(object):
[docs] def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
[docs] def create_app(self, body, async_call=False, **kwargs):
"""
Create a new application with the specified properties.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type body: `AppRequest`
:param body: Properties of application to create (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.create_app_with_http_info(body, async_call=async_call, **kwargs)
else:
(data) = self.create_app_with_http_info(body, async_call=async_call, **kwargs)
return data
def create_app_with_http_info(self, body, async_call=False, **kwargs):
"""
Create a new application with the specified properties.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.create_app_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: `AppRequest`
:param body: Properties of application to create (required)
:rtype: `App`
: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 create_app" % 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 `create_app`")
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/apps', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='App',
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 delete_app(self, app_id, async_call=False, **kwargs):
"""
Remove an application from SDKMS.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.delete_app_with_http_info(app_id, async_call=async_call, **kwargs)
else:
(data) = self.delete_app_with_http_info(app_id, async_call=async_call, **kwargs)
return data
def delete_app_with_http_info(self, app_id, async_call=False, **kwargs):
"""
Remove an application from SDKMS.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.delete_app_with_http_info(app_id, async_call=True)
>>> result = thread.get()
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['app_id']
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 delete_app" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'app_id' is set
if ('app_id' not in params) or (params['app_id'] is None):
raise ValueError("Missing the required parameter `app_id` when calling `delete_app`")
collection_formats = {}
path_params = {}
if 'app_id' in params:
path_params['app-id'] = params['app_id']
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/apps/{app-id}', 'DELETE',
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_app(self, app_id, async_call=False, **kwargs):
"""
Look up an application by application ID.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_app_with_http_info(app_id, async_call=async_call, **kwargs)
else:
(data) = self.get_app_with_http_info(app_id, async_call=async_call, **kwargs)
return data
def get_app_with_http_info(self, app_id, async_call=False, **kwargs):
"""
Look up an application by application ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_app_with_http_info(app_id, async_call=True)
>>> result = thread.get()
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['app_id']
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_app" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'app_id' is set
if ('app_id' not in params) or (params['app_id'] is None):
raise ValueError("Missing the required parameter `app_id` when calling `get_app`")
collection_formats = {}
path_params = {}
if 'app_id' in params:
path_params['app-id'] = params['app_id']
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/apps/{app-id}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='App',
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_apps(self, group_id=None, sort=None, start=None, limit=None, offset=None, async_call=False, **kwargs):
"""
Get details of all applications the current user has access to.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type group_id: `str`
:param group_id: Only retrieve applications in the specified group.
:type sort: `str`
:param sort: This specifies the property (`app_id` only, for now) and order (ascending or descending) with which to sort the apps. By default, apps are sorted by `app_id` in ascending order. The syntax is \"<property>:[asc|desc]\" (e.g. \"app_id:desc\") or just \"<property>\" (ascending order by default).
:type start: `str`
:param start: If provided, this must be a value of the property specified in `sort`. Returned apps will begin just above or just below this value (for asc/desc order resp.).
:type limit: `int`
:param limit: Maximum number of apps to return. If not provided, the limit is 100.
:type offset: `int`
:param offset: Number of apps past `start` to skip.
:rtype: list[`App`]
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_apps_with_http_info(group_id=group_id, sort=sort, start=start, limit=limit, offset=offset, async_call=async_call, **kwargs)
else:
(data) = self.get_apps_with_http_info(group_id=group_id, sort=sort, start=start, limit=limit, offset=offset, async_call=async_call, **kwargs)
return data
def get_apps_with_http_info(self, group_id=None, sort=None, start=None, limit=None, offset=None, async_call=False, **kwargs):
"""
Get details of all applications the current user has access to.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_apps_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).
:type group_id: `str`
:param group_id: Only retrieve applications in the specified group.
:type sort: `str`
:param sort: This specifies the property (`app_id` only, for now) and order (ascending or descending) with which to sort the apps. By default, apps are sorted by `app_id` in ascending order. The syntax is \"<property>:[asc|desc]\" (e.g. \"app_id:desc\") or just \"<property>\" (ascending order by default).
:type start: `str`
:param start: If provided, this must be a value of the property specified in `sort`. Returned apps will begin just above or just below this value (for asc/desc order resp.).
:type limit: `int`
:param limit: Maximum number of apps to return. If not provided, the limit is 100.
:type offset: `int`
:param offset: Number of apps past `start` to skip.
:rtype: list[`App`]
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['group_id', 'sort', 'start', 'limit', 'offset']
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_apps" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
if 'group_id' in params:
query_params.append(('group_id', params['group_id']))
if 'sort' in params:
query_params.append(('sort', params['sort']))
if 'start' in params:
query_params.append(('start', params['start']))
if 'limit' in params:
query_params.append(('limit', params['limit']))
if 'offset' in params:
query_params.append(('offset', params['offset']))
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/apps', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[App]',
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_credential(self, app_id, async_call=False, **kwargs):
"""
Retrieve the authentication credential (API key or certificate) for a particular application. Only users who are an administrator of at least one of the application's groups can retrieve the credential.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: `AppCredentialResponse`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_credential_with_http_info(app_id, async_call=async_call, **kwargs)
else:
(data) = self.get_credential_with_http_info(app_id, async_call=async_call, **kwargs)
return data
def get_credential_with_http_info(self, app_id, async_call=False, **kwargs):
"""
Retrieve the authentication credential (API key or certificate) for a particular application. Only users who are an administrator of at least one of the application's groups can retrieve the credential.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_credential_with_http_info(app_id, async_call=True)
>>> result = thread.get()
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:rtype: `AppCredentialResponse`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['app_id']
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_credential" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'app_id' is set
if ('app_id' not in params) or (params['app_id'] is None):
raise ValueError("Missing the required parameter `app_id` when calling `get_credential`")
collection_formats = {}
path_params = {}
if 'app_id' in params:
path_params['app-id'] = params['app_id']
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/apps/{app-id}/credential', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='AppCredentialResponse',
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 regenerate_api_key(self, app_id, body, async_call=False, **kwargs):
"""
Create a new API key for an application. An application may only have one valid API key at a time, so performing this action will invalidate all old API keys. This does not invalidate existing sessions, so any applications with an existing open session will be able to continue operating with their old session until those sessions expire.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:type body: `AppResetSecretRequest`
:param body: Decryption request (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.regenerate_api_key_with_http_info(app_id, body, async_call=async_call, **kwargs)
else:
(data) = self.regenerate_api_key_with_http_info(app_id, body, async_call=async_call, **kwargs)
return data
def regenerate_api_key_with_http_info(self, app_id, body, async_call=False, **kwargs):
"""
Create a new API key for an application. An application may only have one valid API key at a time, so performing this action will invalidate all old API keys. This does not invalidate existing sessions, so any applications with an existing open session will be able to continue operating with their old session until those sessions expire.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.regenerate_api_key_with_http_info(app_id, 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 app_id: `str`
:param app_id: Application Identifier (required)
:type body: `AppResetSecretRequest`
:param body: Decryption request (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['app_id', '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 regenerate_api_key" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'app_id' is set
if ('app_id' not in params) or (params['app_id'] is None):
raise ValueError("Missing the required parameter `app_id` when calling `regenerate_api_key`")
# 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 `regenerate_api_key`")
collection_formats = {}
path_params = {}
if 'app_id' in params:
path_params['app-id'] = params['app_id']
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/apps/{app-id}/reset_secret', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='App',
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 update_app(self, app_id, body, async_call=False, **kwargs):
"""
Change an application's properties, such as name, description, or group membership.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type app_id: `str`
:param app_id: Application Identifier (required)
:type body: `AppRequest`
:param body: Properties of application to create (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.update_app_with_http_info(app_id, body, async_call=async_call, **kwargs)
else:
(data) = self.update_app_with_http_info(app_id, body, async_call=async_call, **kwargs)
return data
def update_app_with_http_info(self, app_id, body, async_call=False, **kwargs):
"""
Change an application's properties, such as name, description, or group membership.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.update_app_with_http_info(app_id, 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 app_id: `str`
:param app_id: Application Identifier (required)
:type body: `AppRequest`
:param body: Properties of application to create (required)
:rtype: `App`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['app_id', '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 update_app" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'app_id' is set
if ('app_id' not in params) or (params['app_id'] is None):
raise ValueError("Missing the required parameter `app_id` when calling `update_app`")
# 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 `update_app`")
collection_formats = {}
path_params = {}
if 'app_id' in params:
path_params['app-id'] = params['app_id']
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/apps/{app-id}', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='App',
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)