# -*- coding: utf-8 -*-

"""
restapisdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from restapisdk.models.table_list import TableList
from restapisdk.models.user_name_and_id import UserNameAndID


class ConnectionResponse(object):

    """Implementation of the 'ConnectionResponse' model.

    TODO: type model description here.

    Attributes:
        name (string): Name of the connection
        description (string): Description associated with the connection
        mtype (string): Type of the connection. The database associated with
            this type can be obtained from the response returned by the
            /api/rest/v2/connection/types API endpoint.
        id (string): GUID of the connection
        scheduled (bool): Indicates if the data sync is scheduled for this
            connection
        connection_type (string): TODO: type description here.
        configuration (string): Configuration properties of the connection
        is_external (bool): TODO: type description here.
        is_deprecated (bool): Indicates if the connection is deprecated
        is_deleted (bool): Indicates if the connection is deleted
        is_hidden (bool): Indicates if the connection is hideen
        complete (bool): Indicates if the all the properties of connection is
            provided
        index_version (int): TODO: type description here.
        generation_num (int): TODO: type description here.
        created (string): Date and time when the connection was created
        modified (string): Date and time of last modification of the
            connection
        author (UserNameAndID): TODO: type description here.
        modified_by (UserNameAndID): TODO: type description here.
        owner (UserNameAndID): TODO: type description here.
        tags (list of string): List of tags assigned to the connection
        tables (list of TableList): List of tables linked to this connection

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": 'name',
        "description": 'description',
        "mtype": 'type',
        "id": 'id',
        "scheduled": 'scheduled',
        "connection_type": 'connectionType',
        "configuration": 'configuration',
        "is_external": 'isExternal',
        "is_deprecated": 'isDeprecated',
        "is_deleted": 'isDeleted',
        "is_hidden": 'isHidden',
        "complete": 'complete',
        "index_version": 'indexVersion',
        "generation_num": 'generationNum',
        "created": 'created',
        "modified": 'modified',
        "author": 'author',
        "modified_by": 'modifiedBy',
        "owner": 'owner',
        "tags": 'tags',
        "tables": 'tables'
    }

    def __init__(self,
                 name=None,
                 description=None,
                 mtype=None,
                 id=None,
                 scheduled=None,
                 connection_type=None,
                 configuration=None,
                 is_external=None,
                 is_deprecated=None,
                 is_deleted=None,
                 is_hidden=None,
                 complete=None,
                 index_version=None,
                 generation_num=None,
                 created=None,
                 modified=None,
                 author=None,
                 modified_by=None,
                 owner=None,
                 tags=None,
                 tables=None):
        """Constructor for the ConnectionResponse class"""

        # Initialize members of the class
        self.name = name
        self.description = description
        self.mtype = mtype
        self.id = id
        self.scheduled = scheduled
        self.connection_type = connection_type
        self.configuration = configuration
        self.is_external = is_external
        self.is_deprecated = is_deprecated
        self.is_deleted = is_deleted
        self.is_hidden = is_hidden
        self.complete = complete
        self.index_version = index_version
        self.generation_num = generation_num
        self.created = created
        self.modified = modified
        self.author = author
        self.modified_by = modified_by
        self.owner = owner
        self.tags = tags
        self.tables = tables

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if dictionary is None:
            return None

        # Extract variables from the dictionary
        name = dictionary.get('name')
        description = dictionary.get('description')
        mtype = dictionary.get('type')
        id = dictionary.get('id')
        scheduled = dictionary.get('scheduled')
        connection_type = dictionary.get('connectionType')
        configuration = dictionary.get('configuration')
        is_external = dictionary.get('isExternal')
        is_deprecated = dictionary.get('isDeprecated')
        is_deleted = dictionary.get('isDeleted')
        is_hidden = dictionary.get('isHidden')
        complete = dictionary.get('complete')
        index_version = dictionary.get('indexVersion')
        generation_num = dictionary.get('generationNum')
        created = dictionary.get('created')
        modified = dictionary.get('modified')
        author = UserNameAndID.from_dictionary(dictionary.get('author')) if dictionary.get('author') else None
        modified_by = UserNameAndID.from_dictionary(dictionary.get('modifiedBy')) if dictionary.get('modifiedBy') else None
        owner = UserNameAndID.from_dictionary(dictionary.get('owner')) if dictionary.get('owner') else None
        tags = dictionary.get('tags')
        tables = None
        if dictionary.get('tables') is not None:
            tables = [TableList.from_dictionary(x) for x in dictionary.get('tables')]

        # Return an object of this model
        return cls(name,
                   description,
                   mtype,
                   id,
                   scheduled,
                   connection_type,
                   configuration,
                   is_external,
                   is_deprecated,
                   is_deleted,
                   is_hidden,
                   complete,
                   index_version,
                   generation_num,
                   created,
                   modified,
                   author,
                   modified_by,
                   owner,
                   tags,
                   tables)
