# 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 AWSApi(object):
[docs] def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
[docs] def cancel_deletion(self, key_id, async_call=False, **kwargs):
"""
Cancel scheduled deletion of an AWS KMS key
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.cancel_deletion_with_http_info(key_id, async_call=async_call, **kwargs)
else:
(data) = self.cancel_deletion_with_http_info(key_id, async_call=async_call, **kwargs)
return data
def cancel_deletion_with_http_info(self, key_id, async_call=False, **kwargs):
"""
Cancel scheduled deletion of an AWS KMS key
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.cancel_deletion_with_http_info(key_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 key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['key_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 cancel_deletion" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'key_id' is set
if ('key_id' not in params) or (params['key_id'] is None):
raise ValueError("Missing the required parameter `key_id` when calling `cancel_deletion`")
collection_formats = {}
path_params = {}
if 'key_id' in params:
path_params['key-id'] = params['key_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('/crypto/v1/keys/{key-id}/cancel_deletion', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='KeyObject',
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_key_material(self, key_id, async_call=False, **kwargs):
"""
Delete the key material of an AWS KMS key
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.delete_key_material_with_http_info(key_id, async_call=async_call, **kwargs)
else:
(data) = self.delete_key_material_with_http_info(key_id, async_call=async_call, **kwargs)
return data
def delete_key_material_with_http_info(self, key_id, async_call=False, **kwargs):
"""
Delete the key material of an AWS KMS key
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.delete_key_material_with_http_info(key_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 key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['key_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_key_material" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'key_id' is set
if ('key_id' not in params) or (params['key_id'] is None):
raise ValueError("Missing the required parameter `key_id` when calling `delete_key_material`")
collection_formats = {}
path_params = {}
if 'key_id' in params:
path_params['key-id'] = params['key_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('/crypto/v1/keys/{key-id}/delete_key_material', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='KeyObject',
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 restore(self, key_id, async_call=False, **kwargs):
"""
Restore an AWS key from its source key material
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.restore_with_http_info(key_id, async_call=async_call, **kwargs)
else:
(data) = self.restore_with_http_info(key_id, async_call=async_call, **kwargs)
return data
def restore_with_http_info(self, key_id, async_call=False, **kwargs):
"""
Restore an AWS key from its source key material
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.restore_with_http_info(key_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 key_id: `str`
:param key_id: kid of security object (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['key_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 restore" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'key_id' is set
if ('key_id' not in params) or (params['key_id'] is None):
raise ValueError("Missing the required parameter `key_id` when calling `restore`")
collection_formats = {}
path_params = {}
if 'key_id' in params:
path_params['key-id'] = params['key_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('/crypto/v1/keys/{key-id}/restore', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='KeyObject',
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 schedule_deletion(self, key_id, body, async_call=False, **kwargs):
"""
Schedule an AWS KMS key for deletion
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type key_id: `str`
:param key_id: kid of security object (required)
:type body: `ScheduleDeletionRequest`
:param body: Request to schedule deletion for an AWS KMS key (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.schedule_deletion_with_http_info(key_id, body, async_call=async_call, **kwargs)
else:
(data) = self.schedule_deletion_with_http_info(key_id, body, async_call=async_call, **kwargs)
return data
def schedule_deletion_with_http_info(self, key_id, body, async_call=False, **kwargs):
"""
Schedule an AWS KMS key for deletion
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.schedule_deletion_with_http_info(key_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 key_id: `str`
:param key_id: kid of security object (required)
:type body: `ScheduleDeletionRequest`
:param body: Request to schedule deletion for an AWS KMS key (required)
:rtype: `KeyObject`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['key_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 schedule_deletion" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'key_id' is set
if ('key_id' not in params) or (params['key_id'] is None):
raise ValueError("Missing the required parameter `key_id` when calling `schedule_deletion`")
# 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 `schedule_deletion`")
collection_formats = {}
path_params = {}
if 'key_id' in params:
path_params['key-id'] = params['key_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('/crypto/v1/keys/{key-id}/schedule_deletion', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='KeyObject',
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)