# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class ImportAsset(BaseModel):
# 
#     def __init__(
#             self,
#             tenable_uuid=None,
#             fqdn=None,
#             ipv4=None,
#             ipv6=None,
#             netbios_name=None,
#             mac_address=None,
#             ssh_fingerprint=None,
#             operating_system=None,
#             system_type=None,
#             aws_ec2_instance_id=None,
#             aws_ec2_instance_ami_id=None,
#             aws_owner_id=None,
#             aws_availability_zone=None,
#             aws_region=None,
#             aws_vpc_id=None,
#             aws_ec2_instance_group_name=None,
#             aws_ec2_instance_state_name=None,
#             aws_ec2_instance_type=None,
#             aws_subnet_id=None,
#             aws_ec2_product_code=None,
#             aws_ec2_name=None
#     ):
#         self.tenable_uuid = tenable_uuid
#         self.fqdn = fqdn
#         self.ipv4 = ipv4
#         self.ipv6 = ipv6
#         self.netbios_name = netbios_name
#         self.mac_address = mac_address
#         self.ssh_fingerprint = ssh_fingerprint
#         self.operating_system = operating_system
#         self.system_type = system_type
#         self.aws_ec2_instance_id = aws_ec2_instance_id
#         self.aws_ec2_instance_ami_id = aws_ec2_instance_ami_id
#         self.aws_owner_id = aws_owner_id
#         self.aws_availability_zone = aws_availability_zone
#         self.aws_region = aws_region
#         self.aws_vpc_id = aws_vpc_id
#         self.aws_ec2_instance_group_name = aws_ec2_instance_group_name
#         self.aws_ec2_instance_state_name = aws_ec2_instance_state_name
#         self.aws_ec2_instance_type = aws_ec2_instance_type
#         self.aws_subnet_id = aws_subnet_id
#         self.aws_ec2_product_code = aws_ec2_product_code
#         self.aws_ec2_name = aws_ec2_name
# 
# class ImportAssetJob(BaseModel):
# 
#     def __init__(
#             self,
#             job_id=None,
#             container_id=None,
#             source=None,
#             batches=None,
#             uploaded_assets=None,
#             failed_assets=None,
#             start_time=None,
#             last_update_time=None,
#             end_time=None,
#             status=None,
#             status_message=None
#     ):
#         self.job_id = job_id,
#         self.container_id = container_id,
#         self.source = source,
#         self.batches = batches,
#         self.uploaded_assets = uploaded_assets,
#         self.failed_assets = failed_assets,
#         self.start_time = start_time,
#         self.last_update_time = last_update_time,
#         self.end_time = end_time
#         self.status = status
#         self.status_message = status_message
# 
# class ImportAssetJobs(BaseModel):
# 
#     def __init__(
#             self,
#             asset_import_jobs=None
#     ):
#         self._asset_import_jobs = None
# 
#         self.asset_import_jobs = asset_import_jobs
# 
#     @property
#     def asset_import_jobs(self):
#         return self._asset_import_jobs
# 
#     @asset_import_jobs.setter
#     @BaseModel._model_list(ImportAssetJob)
#     def asset_import_jobs(self, asset_import_jobs):
#         self._asset_import_jobs = asset_import_jobs


from json import loads
from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import ImportAsset, ImportAssetJob, ImportAssetJobs



class ImportApi(BaseApi):

    def assets(self, assets_request):
        """Creates job to import assets.

        :param assets_request: An instance of :class:`AssetsRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: The ID of asset import job.
        """
        response = self._client.post('import/assets', assets_request)
        return loads(response.text).get('asset_import_job_uuid')

    def asset_jobs(self):
        """Get list of asset jobs.

        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.ImportAssetJobs`.
        """
        response = self._client.get('import/asset-jobs')

# Path: tenable_io/api/base.py
# class BaseApi(object):
# 
#     def __init__(self, client):
#         self._client = client
# 
# class BaseRequest(object):
# 
#     def as_payload(self, filter_=None):
#         return payload_filter(self.__dict__, filter_)
# 
# Path: tenable_io/api/models.py
# class ImportAsset(BaseModel):
# 
#     def __init__(
#             self,
#             tenable_uuid=None,
#             fqdn=None,
#             ipv4=None,
#             ipv6=None,
#             netbios_name=None,
#             mac_address=None,
#             ssh_fingerprint=None,
#             operating_system=None,
#             system_type=None,
#             aws_ec2_instance_id=None,
#             aws_ec2_instance_ami_id=None,
#             aws_owner_id=None,
#             aws_availability_zone=None,
#             aws_region=None,
#             aws_vpc_id=None,
#             aws_ec2_instance_group_name=None,
#             aws_ec2_instance_state_name=None,
#             aws_ec2_instance_type=None,
#             aws_subnet_id=None,
#             aws_ec2_product_code=None,
#             aws_ec2_name=None
#     ):
#         self.tenable_uuid = tenable_uuid
#         self.fqdn = fqdn
#         self.ipv4 = ipv4
#         self.ipv6 = ipv6
#         self.netbios_name = netbios_name
#         self.mac_address = mac_address
#         self.ssh_fingerprint = ssh_fingerprint
#         self.operating_system = operating_system
#         self.system_type = system_type
#         self.aws_ec2_instance_id = aws_ec2_instance_id
#         self.aws_ec2_instance_ami_id = aws_ec2_instance_ami_id
#         self.aws_owner_id = aws_owner_id
#         self.aws_availability_zone = aws_availability_zone
#         self.aws_region = aws_region
#         self.aws_vpc_id = aws_vpc_id
#         self.aws_ec2_instance_group_name = aws_ec2_instance_group_name
#         self.aws_ec2_instance_state_name = aws_ec2_instance_state_name
#         self.aws_ec2_instance_type = aws_ec2_instance_type
#         self.aws_subnet_id = aws_subnet_id
#         self.aws_ec2_product_code = aws_ec2_product_code
#         self.aws_ec2_name = aws_ec2_name
# 
# class ImportAssetJob(BaseModel):
# 
#     def __init__(
#             self,
#             job_id=None,
#             container_id=None,
#             source=None,
#             batches=None,
#             uploaded_assets=None,
#             failed_assets=None,
#             start_time=None,
#             last_update_time=None,
#             end_time=None,
#             status=None,
#             status_message=None
#     ):
#         self.job_id = job_id,
#         self.container_id = container_id,
#         self.source = source,
#         self.batches = batches,
#         self.uploaded_assets = uploaded_assets,
#         self.failed_assets = failed_assets,
#         self.start_time = start_time,
#         self.last_update_time = last_update_time,
#         self.end_time = end_time
#         self.status = status
#         self.status_message = status_message
# 
# class ImportAssetJobs(BaseModel):
# 
#     def __init__(
#             self,
#             asset_import_jobs=None
#     ):
#         self._asset_import_jobs = None
# 
#         self.asset_import_jobs = asset_import_jobs
# 
#     @property
#     def asset_import_jobs(self):
#         return self._asset_import_jobs
# 
#     @asset_import_jobs.setter
#     @BaseModel._model_list(ImportAssetJob)
#     def asset_import_jobs(self, asset_import_jobs):
#         self._asset_import_jobs = asset_import_jobs


# Path: tenable_io/api/import_.py
from json import loads
from tenable_io.api.base import BaseApi, BaseRequest
from tenable_io.api.models import ImportAsset, ImportAssetJob, ImportAssetJobs




class ImportApi(BaseApi):

    def assets(self, assets_request):
        """Creates job to import assets.

        :param assets_request: An instance of :class:`AssetsRequest`.
        :raise TenableIOApiException:  When API error is encountered.
        :return: The ID of asset import job.
        """
        response = self._client.post('import/assets', assets_request)
        return loads(response.text).get('asset_import_job_uuid')

    def asset_jobs(self):
        """Get list of asset jobs.

        :raise TenableIOApiException:  When API error is encountered.
        :return: An instance of :class:`tenable_io.api.models.ImportAssetJobs`.
        """
        response = self._client.get('import/asset-jobs')

        return ImportAssetJobs.from_json(response.text)