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

"""
    greenbyteapi

    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""

from greenbyteapi.api_helper import APIHelper

class DeviceAccess(object):

    """Implementation of the 'DeviceAccess' model.

    A device access

    Attributes:
        device_access_id (int): The id of a device access.
        site_id (int): The id of a site.
        device_ids (list of int): The associated device ids.
        personnel_ids (list of int): The associated personnel ids.
        task_ids (list of int): The associated task ids.
        timestamp_start (datetime): The timestamp when the device access
            is/was planned to start. The timestamp is in the time zone
            configured in the Greenbyte Platform without UTC offset.
        timestamp_end_expected (datetime): The timestamp when the device
            access is/was planned to end. The timestamp is in the time zone
            configured in the Greenbyte Platform without UTC offset.
        timestamp_end (datetime): The timestamp when the device access
            actually ended. The timestamp is in the time zone configured in
            the Greenbyte Platform without UTC offset.
        log_on_comment (string): A comment for when logging on to the device.
        log_off_comment (string): A comment for when logging off from the
            device.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "device_access_id":'deviceAccessId',
        "site_id":'siteId',
        "device_ids":'deviceIds',
        "personnel_ids":'personnelIds',
        "task_ids":'taskIds',
        "timestamp_start":'timestampStart',
        "timestamp_end_expected":'timestampEndExpected',
        "timestamp_end":'timestampEnd',
        "log_on_comment":'logOnComment',
        "log_off_comment":'logOffComment'
    }

    def __init__(self,
                 device_access_id=None,
                 site_id=None,
                 device_ids=None,
                 personnel_ids=None,
                 task_ids=None,
                 timestamp_start=None,
                 timestamp_end_expected=None,
                 timestamp_end=None,
                 log_on_comment=None,
                 log_off_comment=None):
        """Constructor for the DeviceAccess class"""

        # Initialize members of the class
        self.device_access_id = device_access_id
        self.site_id = site_id
        self.device_ids = device_ids
        self.personnel_ids = personnel_ids
        self.task_ids = task_ids
        self.timestamp_start = APIHelper.RFC3339DateTime(timestamp_start) if timestamp_start else None
        self.timestamp_end_expected = APIHelper.RFC3339DateTime(timestamp_end_expected) if timestamp_end_expected else None
        self.timestamp_end = APIHelper.RFC3339DateTime(timestamp_end) if timestamp_end else None
        self.log_on_comment = log_on_comment
        self.log_off_comment = log_off_comment


    @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
        device_access_id = dictionary.get('deviceAccessId')
        site_id = dictionary.get('siteId')
        device_ids = dictionary.get('deviceIds')
        personnel_ids = dictionary.get('personnelIds')
        task_ids = dictionary.get('taskIds')
        timestamp_start = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestampStart")).datetime if dictionary.get("timestampStart") else None
        timestamp_end_expected = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestampEndExpected")).datetime if dictionary.get("timestampEndExpected") else None
        timestamp_end = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestampEnd")).datetime if dictionary.get("timestampEnd") else None
        log_on_comment = dictionary.get('logOnComment')
        log_off_comment = dictionary.get('logOffComment')

        # Return an object of this model
        return cls(device_access_id,
                   site_id,
                   device_ids,
                   personnel_ids,
                   task_ids,
                   timestamp_start,
                   timestamp_end_expected,
                   timestamp_end,
                   log_on_comment,
                   log_off_comment)


