text: # coding: utf-8
  
  """
      IriusRisk API
  
      Products API  # noqa: E501
  
      OpenAPI spec version: 1
      
      Generated by: https://github.com/swagger-api/swagger-codegen.git
  """
  
  
  from __future__ import absolute_import
  
  import re  # noqa: F401
  
  # python 2 and python 3 compatibility library
  import six
  
  from iriusrisk_python_client_lib.api_client import ApiClient
  
  
  class ControlsApi(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 products_ref_components_component_ref_controls_control_ref_status_put(self, api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, **kwargs):  # noqa: E501
          """Sets the desired status to a countermeasure  # noqa: E501
  
          Sets the desired status to a countermeasure. Possible values are:             - implemented             - recommended             - rejected             - required Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_UPDATE** granted to set any state.   - To have the permission **COUNTERMEASURE_SELECT_IMPLEMENTED** granted to set implemented state.   - To have the permission **COUNTERMEASURE_SELECT_RECOMMENDED** granted to set recommended state.   - To have the permission **COUNTERMEASURE_SELECT_REJECTED** granted to set reject state.   - To have the permission **COUNTERMEASURE_SELECT_REQUIRED** granted to set required state.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_components_component_ref_controls_control_ref_status_put(api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :param str component_ref: ID for component (required)
          :param str control_ref: Control ref (required)
          :param UpdateStatusCountermeasureRequestBody update_status_countermeasure_request_body: JSON data that contains the information to update countermeasure (required)
          :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.products_ref_components_component_ref_controls_control_ref_status_put_with_http_info(api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, **kwargs)  # noqa: E501
          else:
              (data) = self.products_ref_components_component_ref_controls_control_ref_status_put_with_http_info(api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, **kwargs)  # noqa: E501
              return data
  
      def products_ref_components_component_ref_controls_control_ref_status_put_with_http_info(self, api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, **kwargs):  # noqa: E501
          """Sets the desired status to a countermeasure  # noqa: E501
  
          Sets the desired status to a countermeasure. Possible values are:             - implemented             - recommended             - rejected             - required Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_UPDATE** granted to set any state.   - To have the permission **COUNTERMEASURE_SELECT_IMPLEMENTED** granted to set implemented state.   - To have the permission **COUNTERMEASURE_SELECT_RECOMMENDED** granted to set recommended state.   - To have the permission **COUNTERMEASURE_SELECT_REJECTED** granted to set reject state.   - To have the permission **COUNTERMEASURE_SELECT_REQUIRED** granted to set required state.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_components_component_ref_controls_control_ref_status_put_with_http_info(api_token, ref, component_ref, control_ref, update_status_countermeasure_request_body, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :param str component_ref: ID for component (required)
          :param str control_ref: Control ref (required)
          :param UpdateStatusCountermeasureRequestBody update_status_countermeasure_request_body: JSON data that contains the information to update countermeasure (required)
          :return: None
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['api_token', 'ref', 'component_ref', 'control_ref', 'update_status_countermeasure_request_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 products_ref_components_component_ref_controls_control_ref_status_put" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'api_token' is set
          if ('api_token' not in params or
                  params['api_token'] is None):
              raise ValueError("Missing the required parameter `api_token` when calling `products_ref_components_component_ref_controls_control_ref_status_put`")  # noqa: E501
          # verify the required parameter 'ref' is set
          if ('ref' not in params or
                  params['ref'] is None):
              raise ValueError("Missing the required parameter `ref` when calling `products_ref_components_component_ref_controls_control_ref_status_put`")  # noqa: E501
          # verify the required parameter 'component_ref' is set
          if ('component_ref' not in params or
                  params['component_ref'] is None):
              raise ValueError("Missing the required parameter `component_ref` when calling `products_ref_components_component_ref_controls_control_ref_status_put`")  # noqa: E501
          # verify the required parameter 'control_ref' is set
          if ('control_ref' not in params or
                  params['control_ref'] is None):
              raise ValueError("Missing the required parameter `control_ref` when calling `products_ref_components_component_ref_controls_control_ref_status_put`")  # noqa: E501
          # verify the required parameter 'update_status_countermeasure_request_body' is set
          if ('update_status_countermeasure_request_body' not in params or
                  params['update_status_countermeasure_request_body'] is None):
              raise ValueError("Missing the required parameter `update_status_countermeasure_request_body` when calling `products_ref_components_component_ref_controls_control_ref_status_put`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'ref' in params:
              path_params['ref'] = params['ref']  # noqa: E501
          if 'component_ref' in params:
              path_params['componentRef'] = params['component_ref']  # noqa: E501
          if 'control_ref' in params:
              path_params['controlRef'] = params['control_ref']  # noqa: E501
  
          query_params = []
  
          header_params = {}
          if 'api_token' in params:
              header_params['api-token'] = params['api_token']  # noqa: E501
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          if 'update_status_countermeasure_request_body' in params:
              body_params = params['update_status_countermeasure_request_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 = []  # noqa: E501
  
          return self.api_client.call_api(
              '/products/{ref}/components/{componentRef}/controls/{controlRef}/status', 'PUT',
              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 products_ref_controls_get(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all product countermeasures  # noqa: E501
  
          Returns a list of all the countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_get(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.products_ref_controls_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
          else:
              (data) = self.products_ref_controls_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
              return data
  
      def products_ref_controls_get_with_http_info(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all product countermeasures  # noqa: E501
  
          Returns a list of all the countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_get_with_http_info(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['api_token', 'ref']  # 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 products_ref_controls_get" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'api_token' is set
          if ('api_token' not in params or
                  params['api_token'] is None):
              raise ValueError("Missing the required parameter `api_token` when calling `products_ref_controls_get`")  # noqa: E501
          # verify the required parameter 'ref' is set
          if ('ref' not in params or
                  params['ref'] is None):
              raise ValueError("Missing the required parameter `ref` when calling `products_ref_controls_get`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'ref' in params:
              path_params['ref'] = params['ref']  # noqa: E501
  
          query_params = []
  
          header_params = {}
          if 'api_token' in params:
              header_params['api-token'] = params['api_token']  # noqa: E501
  
          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 = []  # noqa: E501
  
          return self.api_client.call_api(
              '/products/{ref}/controls', 'GET',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='list[ComponentControl]',  # 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 products_ref_controls_implemented_get(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all implemented countermeasures of a product.  # noqa: E501
  
          Returns a list of all the implemented countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_implemented_get(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.products_ref_controls_implemented_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
          else:
              (data) = self.products_ref_controls_implemented_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
              return data
  
      def products_ref_controls_implemented_get_with_http_info(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all implemented countermeasures of a product.  # noqa: E501
  
          Returns a list of all the implemented countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_implemented_get_with_http_info(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['api_token', 'ref']  # 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 products_ref_controls_implemented_get" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'api_token' is set
          if ('api_token' not in params or
                  params['api_token'] is None):
              raise ValueError("Missing the required parameter `api_token` when calling `products_ref_controls_implemented_get`")  # noqa: E501
          # verify the required parameter 'ref' is set
          if ('ref' not in params or
                  params['ref'] is None):
              raise ValueError("Missing the required parameter `ref` when calling `products_ref_controls_implemented_get`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'ref' in params:
              path_params['ref'] = params['ref']  # noqa: E501
  
          query_params = []
  
          header_params = {}
          if 'api_token' in params:
              header_params['api-token'] = params['api_token']  # noqa: E501
  
          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 = []  # noqa: E501
  
          return self.api_client.call_api(
              '/products/{ref}/controls/implemented', 'GET',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='list[ComponentControl]',  # 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 products_ref_controls_required_get(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all required countermeasures of a product  # noqa: E501
  
          Returns a list of all the required countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_required_get(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
          kwargs['_return_http_data_only'] = True
          if kwargs.get('async_req'):
              return self.products_ref_controls_required_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
          else:
              (data) = self.products_ref_controls_required_get_with_http_info(api_token, ref, **kwargs)  # noqa: E501
              return data
  
      def products_ref_controls_required_get_with_http_info(self, api_token, ref, **kwargs):  # noqa: E501
          """Gets a list of all required countermeasures of a product  # noqa: E501
  
          Returns a list of all the required countermeasures of a product. Conditions to be able to perform the action:   - To have the permission **COUNTERMEASURE_VIEW** granted, or   - To have the permission **COUNTERMEASURE_UPDATE** granted.   # noqa: E501
          This method makes a synchronous HTTP request by default. To make an
          asynchronous HTTP request, please pass async_req=True
          >>> thread = api.products_ref_controls_required_get_with_http_info(api_token, ref, async_req=True)
          >>> result = thread.get()
  
          :param async_req bool
          :param str api_token: Authentication token (required)
          :param str ref: ID for product (required)
          :return: list[ComponentControl]
                   If the method is called asynchronously,
                   returns the request thread.
          """
  
          all_params = ['api_token', 'ref']  # 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 products_ref_controls_required_get" % key
                  )
              params[key] = val
          del params['kwargs']
          # verify the required parameter 'api_token' is set
          if ('api_token' not in params or
                  params['api_token'] is None):
              raise ValueError("Missing the required parameter `api_token` when calling `products_ref_controls_required_get`")  # noqa: E501
          # verify the required parameter 'ref' is set
          if ('ref' not in params or
                  params['ref'] is None):
              raise ValueError("Missing the required parameter `ref` when calling `products_ref_controls_required_get`")  # noqa: E501
  
          collection_formats = {}
  
          path_params = {}
          if 'ref' in params:
              path_params['ref'] = params['ref']  # noqa: E501
  
          query_params = []
  
          header_params = {}
          if 'api_token' in params:
              header_params['api-token'] = params['api_token']  # noqa: E501
  
          form_params = []
          local_var_files = {}
  
          body_params = None
          # 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 = []  # noqa: E501
  
          return self.api_client.call_api(
              '/products/{ref}/controls/required', 'GET',
              path_params,
              query_params,
              header_params,
              body=body_params,
              post_params=form_params,
              files=local_var_files,
              response_type='list[ComponentControl]',  # 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)
  