# 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 ApprovalRequestsApi(object):
[docs] def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
[docs] def approve(self, request_id, body=None, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type request_id: `str`
:param request_id: Approval Request Identifier (required)
:type body: `ApproveRequest`
:param body: Approve an approval request
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.approve_with_http_info(request_id, body=body, async_call=async_call, **kwargs)
else:
(data) = self.approve_with_http_info(request_id, body=body, async_call=async_call, **kwargs)
return data
def approve_with_http_info(self, request_id, body=None, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.approve_with_http_info(request_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 request_id: `str`
:param request_id: Approval Request Identifier (required)
:type body: `ApproveRequest`
:param body: Approve an approval request
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['request_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 approve" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'request_id' is set
if ('request_id' not in params) or (params['request_id'] is None):
raise ValueError("Missing the required parameter `request_id` when calling `approve`")
collection_formats = {}
path_params = {}
if 'request_id' in params:
path_params['request-id'] = params['request_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/approval_requests/{request-id}/approve', '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 create_approval_request(self, body, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type body: `ApprovalRequestRequest`
:param body: Request to create an approval request. (required)
:rtype: `ApprovalRequest`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.create_approval_request_with_http_info(body, async_call=async_call, **kwargs)
else:
(data) = self.create_approval_request_with_http_info(body, async_call=async_call, **kwargs)
return data
def create_approval_request_with_http_info(self, body, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.create_approval_request_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: `ApprovalRequestRequest`
:param body: Request to create an approval request. (required)
:rtype: `ApprovalRequest`
: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_approval_request" % 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_approval_request`")
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/approval_requests', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApprovalRequest',
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_approval_request(self, request_id, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type request_id: `str`
:param request_id: Approval Request 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_approval_request_with_http_info(request_id, async_call=async_call, **kwargs)
else:
(data) = self.delete_approval_request_with_http_info(request_id, async_call=async_call, **kwargs)
return data
def delete_approval_request_with_http_info(self, request_id, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.delete_approval_request_with_http_info(request_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 request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['request_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_approval_request" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'request_id' is set
if ('request_id' not in params) or (params['request_id'] is None):
raise ValueError("Missing the required parameter `request_id` when calling `delete_approval_request`")
collection_formats = {}
path_params = {}
if 'request_id' in params:
path_params['request-id'] = params['request_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/approval_requests/{request-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 deny(self, request_id, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type request_id: `str`
:param request_id: Approval Request 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.deny_with_http_info(request_id, async_call=async_call, **kwargs)
else:
(data) = self.deny_with_http_info(request_id, async_call=async_call, **kwargs)
return data
def deny_with_http_info(self, request_id, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.deny_with_http_info(request_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 request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: None
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['request_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 deny" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'request_id' is set
if ('request_id' not in params) or (params['request_id'] is None):
raise ValueError("Missing the required parameter `request_id` when calling `deny`")
collection_formats = {}
path_params = {}
if 'request_id' in params:
path_params['request-id'] = params['request_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/approval_requests/{request-id}/deny', '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 get_approval_request(self, request_id, async_call=False, **kwargs):
"""
Get the details and status of a particular approval request.
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: `ApprovalRequest`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_approval_request_with_http_info(request_id, async_call=async_call, **kwargs)
else:
(data) = self.get_approval_request_with_http_info(request_id, async_call=async_call, **kwargs)
return data
def get_approval_request_with_http_info(self, request_id, async_call=False, **kwargs):
"""
Get the details and status of a particular approval request.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_approval_request_with_http_info(request_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 request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: `ApprovalRequest`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['request_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_approval_request" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'request_id' is set
if ('request_id' not in params) or (params['request_id'] is None):
raise ValueError("Missing the required parameter `request_id` when calling `get_approval_request`")
collection_formats = {}
path_params = {}
if 'request_id' in params:
path_params['request-id'] = params['request_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/approval_requests/{request-id}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApprovalRequest',
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_approval_requests(self, requester=None, reviewer=None, subject=None, status=None, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type requester: `str`
:param requester: Only retrieve approval requests with the specified requester ID
:type reviewer: `str`
:param reviewer: Only retrieve approval requests with the specified reviewer ID
:type subject: `str`
:param subject: Only retrieve approval requests with the specified subject ID
:type status: `str`
:param status: Only retrieve approval requests with the specified approval status
:rtype: list[`ApprovalRequest`]
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_approval_requests_with_http_info(requester=requester, reviewer=reviewer, subject=subject, status=status, async_call=async_call, **kwargs)
else:
(data) = self.get_approval_requests_with_http_info(requester=requester, reviewer=reviewer, subject=subject, status=status, async_call=async_call, **kwargs)
return data
def get_approval_requests_with_http_info(self, requester=None, reviewer=None, subject=None, status=None, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_approval_requests_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 requester: `str`
:param requester: Only retrieve approval requests with the specified requester ID
:type reviewer: `str`
:param reviewer: Only retrieve approval requests with the specified reviewer ID
:type subject: `str`
:param subject: Only retrieve approval requests with the specified subject ID
:type status: `str`
:param status: Only retrieve approval requests with the specified approval status
:rtype: list[`ApprovalRequest`]
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['requester', 'reviewer', 'subject', 'status']
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_approval_requests" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
if 'requester' in params:
query_params.append(('requester', params['requester']))
if 'reviewer' in params:
query_params.append(('reviewer', params['reviewer']))
if 'subject' in params:
query_params.append(('subject', params['subject']))
if 'status' in params:
query_params.append(('status', params['status']))
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/approval_requests', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[ApprovalRequest]',
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_result(self, request_id, async_call=False, **kwargs):
"""
:type async_call: bool
:param async_call: Whether the call should be performed asynchronously. (Default is False).
:type request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: `ApprovableResult`
:return:
If the method is called asynchronously, returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if async_call:
return self.get_result_with_http_info(request_id, async_call=async_call, **kwargs)
else:
(data) = self.get_result_with_http_info(request_id, async_call=async_call, **kwargs)
return data
def get_result_with_http_info(self, request_id, async_call=False, **kwargs):
"""
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_call=True::
>>> thread = api.get_result_with_http_info(request_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 request_id: `str`
:param request_id: Approval Request Identifier (required)
:rtype: `ApprovableResult`
:return:
If the method is called asynchronously, returns the request thread.
"""
all_params = ['request_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_result" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'request_id' is set
if ('request_id' not in params) or (params['request_id'] is None):
raise ValueError("Missing the required parameter `request_id` when calling `get_result`")
collection_formats = {}
path_params = {}
if 'request_id' in params:
path_params['request-id'] = params['request_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/approval_requests/{request-id}/result', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApprovableResult',
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)