# coding=utf-8
r"""
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
"""

from twilio.base import deserialize
from twilio.base import serialize
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.page import Page


class SyncListItemList(ListResource):
    """ PLEASE NOTE that this class contains preview products that are subject
    to change. Use them with caution. If you currently do not have developer
    preview access, please contact help@twilio.com. """

    def __init__(self, version, service_sid, list_sid):
        """
        Initialize the SyncListItemList

        :param Version version: Version that contains the resource
        :param service_sid: The service_sid
        :param list_sid: The list_sid

        :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList
        :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList
        """
        super(SyncListItemList, self).__init__(version)

        # Path Solution
        self._solution = {'service_sid': service_sid, 'list_sid': list_sid, }
        self._uri = '/Services/{service_sid}/Lists/{list_sid}/Items'.format(**self._solution)

    def create(self, data):
        """
        Create the SyncListItemInstance

        :param dict data: The data

        :returns: The created SyncListItemInstance
        :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance
        """
        data = values.of({'Data': serialize.object(data), })

        payload = self._version.create(method='POST', uri=self._uri, data=data, )

        return SyncListItemInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            list_sid=self._solution['list_sid'],
        )

    def stream(self, order=values.unset, from_=values.unset, bounds=values.unset,
               limit=None, page_size=None):
        """
        Streams SyncListItemInstance records from the API as a generator stream.
        This operation lazily loads records as efficiently as possible until the limit
        is reached.
        The results are returned as a generator, so this operation is memory efficient.

        :param SyncListItemInstance.QueryResultOrder order: The order
        :param unicode from_: The from
        :param SyncListItemInstance.QueryFromBoundType bounds: The bounds
        :param int limit: Upper limit for the number of records to return. stream()
                          guarantees to never return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, stream() will attempt to read the
                              limit with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        :rtype: list[twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance]
        """
        limits = self._version.read_limits(limit, page_size)

        page = self.page(order=order, from_=from_, bounds=bounds, page_size=limits['page_size'], )

        return self._version.stream(page, limits['limit'])

    def list(self, order=values.unset, from_=values.unset, bounds=values.unset,
             limit=None, page_size=None):
        """
        Lists SyncListItemInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param SyncListItemInstance.QueryResultOrder order: The order
        :param unicode from_: The from
        :param SyncListItemInstance.QueryFromBoundType bounds: The bounds
        :param int limit: Upper limit for the number of records to return. list() guarantees
                          never to return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, list() will attempt to read the limit
                              with the most efficient page size, i.e. min(limit, 1000)