# Path: tenable_io/api/credentials.py
# class CredentialRequest(BaseRequest):
# 
#     def __init__(
#             self,
#             name=None,
#             description=None,
#             type_=None,
#             settings=None,
#             permissions=None
#     ):
#         """Request for CredentialsApi.create and CredentialsApi.update.
# 
#         :param name: The name of the managed credential. This name must be unique within your Tenable.io instance.
#         :type name: str
#         :param description: The description of the managed credential object.
#         :type description: str
#         :param type_: The type of credential object. For a list of supported credential types, use the
#             :func:`~tenable_io.CredentialsApi.types` method to get a list of possible types and the
#             required configuration for each.
#         :type type_: str
#         :param settings: The configuration settings for the credential. The parameters of this object vary depending on
#             the credential type. For more information, see our documentation at
#             https://developer.tenable.com/docs/determine-settings-for-credential-type
#         :type settings: dict
#         :param permissions: A list of :class:`tenable_io.api.models.CredentialPermissions` objects to specify the
#             permissions for the managed credential.
#         :type permissions: list
#         """
#         if permissions is not None:
#             for p in permissions:
#                 assert isinstance(p, CredentialPermission)
# 
#         self.name = name
#         self.description = description
#         self.type = type_
#         self.settings = settings
#         self.permissions = permissions
# 
#     def as_payload(self, filter_=None):
#         payload = super(CredentialRequest, self).as_payload(True)
#         _permissions = []
#         if self.permissions is not None:
#             for p in self.permissions:
#                 _permissions.append(p.as_payload(True))
#             payload.__setitem__("permissions", _permissions)
#         return payload
# 
# Path: tenable_io/api/models.py
# class CredentialDetails(BaseModel):
# 
#     def __init__(
#             self,
#             uuid=None,
#             name=None,
#             description=None,
#             category=None,
#             type=None,
#             permission=None,
#             user_permissions=None,
#             settings=None,
#             ad_hoc=None,
#     ):
#         self._category = None
#         self._type = None
#         self._permissions = None
#         self._settings = None
# 
#         self.uuid = uuid
#         self.name = name
#         self.description = description
#         self.category = category
#         self.type = type
#         self.permission = permission
#         self.user_permissions = user_permissions
#         self.settings = settings
#         self.ad_hoc = ad_hoc
# 
#     @property
#     def category(self):
#         return self._category
# 
#     @category.setter
#     @BaseModel._model(CredentialCategory)
#     def category(self, category):
#         self._category = category
# 
#     @property
#     def type(self):
#         return self._type
# 
#     @type.setter
#     @BaseModel._model(CredentialType)
#     def type(self, type):
#         self._type = type
# 
#     @property
#     def settings(self):
#         return self._settings
# 
#     @settings.setter
#     @BaseModel._model(CredentialSettings)
#     def settings(self, settings):
#         self._settings = settings
# 
#     @property
#     def permissions(self):
#         return self._permissions
# 
#     @permissions.setter
#     @BaseModel._model_list(CredentialPermission)
#     def permissions(self, permissions):
#         self._permissions = permissions
# 
# class CredentialList(BaseModel):
# 
#     def __init__(
#             self,
#             credentials=None,
#             pagination=None
#     ):
#         self._credentials = None
#         self._pagination = None
#         self.credentials = credentials
#         self.pagination = pagination
# 
#     @property
#     def credentials(self):
#         return self._credentials
# 
#     @credentials.setter
#     @BaseModel._model_list(Credential)
#     def credentials(self, credentials):
#         self._credentials = credentials
# 
#     @property
#     def pagination(self):
#         return self._pagination
# 
#     @pagination.setter
#     @BaseModel._model(FilterPagination)
#     def pagination(self, pagination):
#         self._pagination = pagination
# 
# class CredentialPermission(BaseModel):
# 
#     USER_TYPE = u'user'
#     GROUP_TYPE = u'group'
# 
#     CAN_USE = 32
#     CAN_EDIT = 64
# 
#     def __init__(
#             self,
#             grantee_uuid=None,
#             type=None,
#             permissions=None,
#             name=None,
#             isPending=None
#     ):
#         self.grantee_uuid = grantee_uuid
#         self.type = type
#         self.permissions = permissions
#         self.name = name
#         self.isPending = isPending
# 
# class CredentialPrimitiveType(BaseModel):
# 
#     def __init__(
#             self,
#             id=None,
#             category=None,
#             default_expand=None,
#             types=None,
#     ):
#         self._types = None
# 
#         self.id = id
#         self.category = category
#         self.default_expand = default_expand
#         self.types = types
# 
#     @property
#     def types(self):
#         return self._types
# 
#     @types.setter
#     @BaseModel._model_list(CredentialTypes)
#     def types(self, types):
#         self._types = types


import pytest
from random import randint
from tenable_io.api.credentials import CredentialRequest
from tenable_io.api.models import CredentialDetails, CredentialList, CredentialPermission, CredentialPrimitiveType



@pytest.mark.vcr()
def test_managed_credential_details(client):
    new_credential_uuid = create_managed_credential(client)
    resp = client.credentials_api.details(uuid=new_credential_uuid)
    assert isinstance(resp, CredentialDetails), u'The `details` method did not return type `CredentialDetails`.'
    assert resp.type.name == 'Windows', u'Expected the returned type to match the configured type.'


@pytest.mark.vcr()
def test_managed_credential_list(client):
    resp = client.credentials_api.list()

# Path: tenable_io/api/credentials.py
# class CredentialRequest(BaseRequest):
# 
#     def __init__(
#             self,
#             name=None,
#             description=None,
#             type_=None,
#             settings=None,
#             permissions=None
#     ):
#         """Request for CredentialsApi.create and CredentialsApi.update.
# 
#         :param name: The name of the managed credential. This name must be unique within your Tenable.io instance.
#         :type name: str
#         :param description: The description of the managed credential object.
#         :type description: str
#         :param type_: The type of credential object. For a list of supported credential types, use the
#             :func:`~tenable_io.CredentialsApi.types` method to get a list of possible types and the
#             required configuration for each.
#         :type type_: str
#         :param settings: The configuration settings for the credential. The parameters of this object vary depending on
#             the credential type. For more information, see our documentation at
#             https://developer.tenable.com/docs/determine-settings-for-credential-type
#         :type settings: dict
#         :param permissions: A list of :class:`tenable_io.api.models.CredentialPermissions` objects to specify the
#             permissions for the managed credential.
#         :type permissions: list
#         """
#         if permissions is not None:
#             for p in permissions:
#                 assert isinstance(p, CredentialPermission)
# 
#         self.name = name
#         self.description = description
#         self.type = type_
#         self.settings = settings
#         self.permissions = permissions
# 
#     def as_payload(self, filter_=None):
#         payload = super(CredentialRequest, self).as_payload(True)
#         _permissions = []
#         if self.permissions is not None:
#             for p in self.permissions:
#                 _permissions.append(p.as_payload(True))
#             payload.__setitem__("permissions", _permissions)
#         return payload
# 
# Path: tenable_io/api/models.py
# class CredentialDetails(BaseModel):
# 
#     def __init__(
#             self,
#             uuid=None,
#             name=None,
#             description=None,
#             category=None,
#             type=None,
#             permission=None,
#             user_permissions=None,
#             settings=None,
#             ad_hoc=None,
#     ):
#         self._category = None
#         self._type = None
#         self._permissions = None
#         self._settings = None
# 
#         self.uuid = uuid
#         self.name = name
#         self.description = description
#         self.category = category
#         self.type = type
#         self.permission = permission
#         self.user_permissions = user_permissions
#         self.settings = settings
#         self.ad_hoc = ad_hoc
# 
#     @property
#     def category(self):
#         return self._category
# 
#     @category.setter
#     @BaseModel._model(CredentialCategory)
#     def category(self, category):
#         self._category = category
# 
#     @property
#     def type(self):
#         return self._type
# 
#     @type.setter
#     @BaseModel._model(CredentialType)
#     def type(self, type):
#         self._type = type
# 
#     @property
#     def settings(self):
#         return self._settings
# 
#     @settings.setter
#     @BaseModel._model(CredentialSettings)
#     def settings(self, settings):
#         self._settings = settings
# 
#     @property
#     def permissions(self):
#         return self._permissions
# 
#     @permissions.setter
#     @BaseModel._model_list(CredentialPermission)
#     def permissions(self, permissions):
#         self._permissions = permissions
# 
# class CredentialList(BaseModel):
# 
#     def __init__(
#             self,
#             credentials=None,
#             pagination=None
#     ):
#         self._credentials = None
#         self._pagination = None
#         self.credentials = credentials
#         self.pagination = pagination
# 
#     @property
#     def credentials(self):
#         return self._credentials
# 
#     @credentials.setter
#     @BaseModel._model_list(Credential)
#     def credentials(self, credentials):
#         self._credentials = credentials
# 
#     @property
#     def pagination(self):
#         return self._pagination
# 
#     @pagination.setter
#     @BaseModel._model(FilterPagination)
#     def pagination(self, pagination):
#         self._pagination = pagination
# 
# class CredentialPermission(BaseModel):
# 
#     USER_TYPE = u'user'
#     GROUP_TYPE = u'group'
# 
#     CAN_USE = 32
#     CAN_EDIT = 64
# 
#     def __init__(
#             self,
#             grantee_uuid=None,
#             type=None,
#             permissions=None,
#             name=None,
#             isPending=None
#     ):
#         self.grantee_uuid = grantee_uuid
#         self.type = type
#         self.permissions = permissions
#         self.name = name
#         self.isPending = isPending
# 
# class CredentialPrimitiveType(BaseModel):
# 
#     def __init__(
#             self,
#             id=None,
#             category=None,
#             default_expand=None,
#             types=None,
#     ):
#         self._types = None
# 
#         self.id = id
#         self.category = category
#         self.default_expand = default_expand
#         self.types = types
# 
#     @property
#     def types(self):
#         return self._types
# 
#     @types.setter
#     @BaseModel._model_list(CredentialTypes)
#     def types(self, types):
#         self._types = types


# Path: tests/integration/api/test_credentials.py
import pytest
from random import randint
from tenable_io.api.credentials import CredentialRequest
from tenable_io.api.models import CredentialDetails, CredentialList, CredentialPermission, CredentialPrimitiveType




@pytest.mark.vcr()
def test_managed_credential_details(client):
    new_credential_uuid = create_managed_credential(client)
    resp = client.credentials_api.details(uuid=new_credential_uuid)
    assert isinstance(resp, CredentialDetails), u'The `details` method did not return type `CredentialDetails`.'
    assert resp.type.name == 'Windows', u'Expected the returned type to match the configured type.'


@pytest.mark.vcr()
def test_managed_credential_list(client):
    resp = client.credentials_api.list()

    assert isinstance(resp, CredentialList), u'The `list` method did not return type `CredentialList`.'