# coding: utf-8

"""
    Lists

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: v3
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from hubspot.crm.lists.api_client import ApiClient
from hubspot.crm.lists.exceptions import ApiTypeError, ApiValueError  # noqa: F401


class MembershipsApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def add(self, list_id, request_body, **kwargs):  # noqa: E501
        """Add Records to a List  # noqa: E501

        Add the records provided to the list. Records that do not exist or that are already members of the list are ignored.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add(list_id, request_body, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param request_body: (required)
        :type request_body: list[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: MembershipsUpdateResponse
        """
        kwargs["_return_http_data_only"] = True
        return self.add_with_http_info(list_id, request_body, **kwargs)  # noqa: E501

    def add_with_http_info(self, list_id, request_body, **kwargs):  # noqa: E501
        """Add Records to a List  # noqa: E501

        Add the records provided to the list. Records that do not exist or that are already members of the list are ignored.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add_with_http_info(list_id, request_body, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param request_body: (required)
        :type request_body: list[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(MembershipsUpdateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["list_id", "request_body"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method add" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `add`")  # noqa: E501
        # verify the required parameter 'request_body' is set
        if self.api_client.client_side_validation and local_var_params.get("request_body") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `request_body` when calling `add`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        if "request_body" in local_var_params:
            body_params = local_var_params["request_body"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # HTTP header `Content-Type`
        content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/json"], "PUT", body_params))  # noqa: E501
        if content_types_list:
            header_params["Content-Type"] = content_types_list

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "MembershipsUpdateResponse",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships/add",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def add_all_from_list(self, list_id, source_list_id, **kwargs):  # noqa: E501
        """Add All Records from a Source List to a Destination List  # noqa: E501

        Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.).  This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`.  This endpoint only supports a `sourceListId` for lists with less than 100,000 memberships.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add_all_from_list(list_id, source_list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to. (required)
        :type list_id: str
        :param source_list_id: The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*. (required)
        :type source_list_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """
        kwargs["_return_http_data_only"] = True
        return self.add_all_from_list_with_http_info(list_id, source_list_id, **kwargs)  # noqa: E501

    def add_all_from_list_with_http_info(self, list_id, source_list_id, **kwargs):  # noqa: E501
        """Add All Records from a Source List to a Destination List  # noqa: E501

        Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.).  This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`.  This endpoint only supports a `sourceListId` for lists with less than 100,000 memberships.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add_all_from_list_with_http_info(list_id, source_list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to. (required)
        :type list_id: str
        :param source_list_id: The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*. (required)
        :type source_list_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """

        local_var_params = locals()

        all_params = ["list_id", "source_list_id"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method add_all_from_list" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `add_all_from_list`")  # noqa: E501
        # verify the required parameter 'source_list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("source_list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `source_list_id` when calling `add_all_from_list`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501
        if "source_list_id" in local_var_params:
            path_params["sourceListId"] = local_var_params["source_list_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["*/*"])  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {}

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships/add-from/{sourceListId}",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def add_and_remove(self, list_id, membership_change_request, **kwargs):  # noqa: E501
        """Add and/or Remove Records from a List  # noqa: E501

        Add and/or remove records that have already been created in the system to and/or from a list.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add_and_remove(list_id, membership_change_request, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param membership_change_request: (required)
        :type membership_change_request: MembershipChangeRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: MembershipsUpdateResponse
        """
        kwargs["_return_http_data_only"] = True
        return self.add_and_remove_with_http_info(list_id, membership_change_request, **kwargs)  # noqa: E501

    def add_and_remove_with_http_info(self, list_id, membership_change_request, **kwargs):  # noqa: E501
        """Add and/or Remove Records from a List  # noqa: E501

        Add and/or remove records that have already been created in the system to and/or from a list.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.add_and_remove_with_http_info(list_id, membership_change_request, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param membership_change_request: (required)
        :type membership_change_request: MembershipChangeRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(MembershipsUpdateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["list_id", "membership_change_request"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method add_and_remove" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `add_and_remove`")  # noqa: E501
        # verify the required parameter 'membership_change_request' is set
        if self.api_client.client_side_validation and local_var_params.get("membership_change_request") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `membership_change_request` when calling `add_and_remove`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        if "membership_change_request" in local_var_params:
            body_params = local_var_params["membership_change_request"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # HTTP header `Content-Type`
        content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/json"], "PUT", body_params))  # noqa: E501
        if content_types_list:
            header_params["Content-Type"] = content_types_list

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "MembershipsUpdateResponse",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships/add-and-remove",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def get_lists(self, object_type_id, record_id, **kwargs):  # noqa: E501
        """Get lists record is member of  # noqa: E501

        For given record provide lists this record is member of.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_lists(object_type_id, record_id, async_req=True)
        >>> result = thread.get()

        :param object_type_id: Object type id of the record (required)
        :type object_type_id: str
        :param record_id: Id of the record (required)
        :type record_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ApiCollectionResponseRecordListMembershipNoPaging
        """
        kwargs["_return_http_data_only"] = True
        return self.get_lists_with_http_info(object_type_id, record_id, **kwargs)  # noqa: E501

    def get_lists_with_http_info(self, object_type_id, record_id, **kwargs):  # noqa: E501
        """Get lists record is member of  # noqa: E501

        For given record provide lists this record is member of.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_lists_with_http_info(object_type_id, record_id, async_req=True)
        >>> result = thread.get()

        :param object_type_id: Object type id of the record (required)
        :type object_type_id: str
        :param record_id: Id of the record (required)
        :type record_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ApiCollectionResponseRecordListMembershipNoPaging, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["object_type_id", "record_id"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_lists" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'object_type_id' is set
        if self.api_client.client_side_validation and local_var_params.get("object_type_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `object_type_id` when calling `get_lists`")  # noqa: E501
        # verify the required parameter 'record_id' is set
        if self.api_client.client_side_validation and local_var_params.get("record_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `record_id` when calling `get_lists`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "object_type_id" in local_var_params:
            path_params["objectTypeId"] = local_var_params["object_type_id"]  # noqa: E501
        if "record_id" in local_var_params:
            path_params["recordId"] = local_var_params["record_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "ApiCollectionResponseRecordListMembershipNoPaging",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/records/{objectTypeId}/{recordId}/memberships",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def get_page(self, list_id, **kwargs):  # noqa: E501
        """Fetch List Memberships Ordered by ID  # noqa: E501

        Fetch the memberships of a list in order sorted by the `recordId` of the records in the list.  The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order.  The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_page(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the list. (required)
        :type list_id: str
        :param after: The paging offset token for the page that comes `after` the previously requested records.  If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
        :type after: str
        :param before: The paging offset token for the page that comes `before` the previously requested records.  If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
        :type before: str
        :param limit: The number of records to return in the response. The maximum `limit` is 250.
        :type limit: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ApiCollectionResponseJoinTimeAndRecordId
        """
        kwargs["_return_http_data_only"] = True
        return self.get_page_with_http_info(list_id, **kwargs)  # noqa: E501

    def get_page_with_http_info(self, list_id, **kwargs):  # noqa: E501
        """Fetch List Memberships Ordered by ID  # noqa: E501

        Fetch the memberships of a list in order sorted by the `recordId` of the records in the list.  The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order.  The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_page_with_http_info(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the list. (required)
        :type list_id: str
        :param after: The paging offset token for the page that comes `after` the previously requested records.  If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
        :type after: str
        :param before: The paging offset token for the page that comes `before` the previously requested records.  If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
        :type before: str
        :param limit: The number of records to return in the response. The maximum `limit` is 250.
        :type limit: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ApiCollectionResponseJoinTimeAndRecordId, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["list_id", "after", "before", "limit"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_page" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `get_page`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []
        if local_var_params.get("after") is not None:  # noqa: E501
            query_params.append(("after", local_var_params["after"]))  # noqa: E501
        if local_var_params.get("before") is not None:  # noqa: E501
            query_params.append(("before", local_var_params["before"]))  # noqa: E501
        if local_var_params.get("limit") is not None:  # noqa: E501
            query_params.append(("limit", local_var_params["limit"]))  # noqa: E501

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "ApiCollectionResponseJoinTimeAndRecordId",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def get_page_ordered_by_added_to_list_date(self, list_id, **kwargs):  # noqa: E501
        """Fetch List Memberships Ordered by Added to List Date  # noqa: E501

        Fetch the memberships of a list in order sorted by the time the records were added to the list.  The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order.  The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_page_ordered_by_added_to_list_date(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the list. (required)
        :type list_id: str
        :param after: The paging offset token for the page that comes `after` the previously requested records.  If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
        :type after: str
        :param before: The paging offset token for the page that comes `before` the previously requested records.  If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
        :type before: str
        :param limit: The number of records to return in the response. The maximum `limit` is 250.
        :type limit: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ApiCollectionResponseJoinTimeAndRecordId
        """
        kwargs["_return_http_data_only"] = True
        return self.get_page_ordered_by_added_to_list_date_with_http_info(list_id, **kwargs)  # noqa: E501

    def get_page_ordered_by_added_to_list_date_with_http_info(self, list_id, **kwargs):  # noqa: E501
        """Fetch List Memberships Ordered by Added to List Date  # noqa: E501

        Fetch the memberships of a list in order sorted by the time the records were added to the list.  The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order.  The `after` offset parameter will take precedence over the `before` offset in a case where both are provided.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_page_ordered_by_added_to_list_date_with_http_info(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the list. (required)
        :type list_id: str
        :param after: The paging offset token for the page that comes `after` the previously requested records.  If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset.
        :type after: str
        :param before: The paging offset token for the page that comes `before` the previously requested records.  If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order.
        :type before: str
        :param limit: The number of records to return in the response. The maximum `limit` is 250.
        :type limit: int
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ApiCollectionResponseJoinTimeAndRecordId, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["list_id", "after", "before", "limit"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_page_ordered_by_added_to_list_date" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `get_page_ordered_by_added_to_list_date`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []
        if local_var_params.get("after") is not None:  # noqa: E501
            query_params.append(("after", local_var_params["after"]))  # noqa: E501
        if local_var_params.get("before") is not None:  # noqa: E501
            query_params.append(("before", local_var_params["before"]))  # noqa: E501
        if local_var_params.get("limit") is not None:  # noqa: E501
            query_params.append(("limit", local_var_params["limit"]))  # noqa: E501

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "ApiCollectionResponseJoinTimeAndRecordId",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships/join-order",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def remove(self, list_id, request_body, **kwargs):  # noqa: E501
        """Remove Records from a List  # noqa: E501

        Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove(list_id, request_body, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param request_body: (required)
        :type request_body: list[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: MembershipsUpdateResponse
        """
        kwargs["_return_http_data_only"] = True
        return self.remove_with_http_info(list_id, request_body, **kwargs)  # noqa: E501

    def remove_with_http_info(self, list_id, request_body, **kwargs):  # noqa: E501
        """Remove Records from a List  # noqa: E501

        Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored.  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove_with_http_info(list_id, request_body, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param request_body: (required)
        :type request_body: list[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(MembershipsUpdateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        local_var_params = locals()

        all_params = ["list_id", "request_body"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method remove" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `remove`")  # noqa: E501
        # verify the required parameter 'request_body' is set
        if self.api_client.client_side_validation and local_var_params.get("request_body") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `request_body` when calling `remove`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        if "request_body" in local_var_params:
            body_params = local_var_params["request_body"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/json", "*/*"])  # noqa: E501

        # HTTP header `Content-Type`
        content_types_list = local_var_params.get("_content_type", self.api_client.select_header_content_type(["application/json"], "PUT", body_params))  # noqa: E501
        if content_types_list:
            header_params["Content-Type"] = content_types_list

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {
            200: "MembershipsUpdateResponse",
        }

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships/remove",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )

    def remove_all(self, list_id, **kwargs):  # noqa: E501
        """Delete All Records from a List  # noqa: E501

        Remove **all** of the records from a list. ***Note:*** *The list is not deleted.*  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  This endpoint only supports lists that have less than 100,000 memberships.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove_all(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """
        kwargs["_return_http_data_only"] = True
        return self.remove_all_with_http_info(list_id, **kwargs)  # noqa: E501

    def remove_all_with_http_info(self, list_id, **kwargs):  # noqa: E501
        """Delete All Records from a List  # noqa: E501

        Remove **all** of the records from a list. ***Note:*** *The list is not deleted.*  This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`.  This endpoint only supports lists that have less than 100,000 memberships.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove_all_with_http_info(list_id, async_req=True)
        >>> result = thread.get()

        :param list_id: The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. (required)
        :type list_id: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _return_http_data_only: response data without head status code
                                       and headers
        :type _return_http_data_only: bool, optional
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :type _preload_content: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """

        local_var_params = locals()

        all_params = ["list_id"]
        all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout", "_request_auth", "_content_type", "_headers"])

        for key, val in six.iteritems(local_var_params["kwargs"]):
            if key not in all_params:
                raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method remove_all" % key)
            local_var_params[key] = val
        del local_var_params["kwargs"]
        # verify the required parameter 'list_id' is set
        if self.api_client.client_side_validation and local_var_params.get("list_id") is None:  # noqa: E501
            raise ApiValueError("Missing the required parameter `list_id` when calling `remove_all`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if "list_id" in local_var_params:
            path_params["listId"] = local_var_params["list_id"]  # noqa: E501

        query_params = []

        header_params = dict(local_var_params.get("_headers", {}))

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["*/*"])  # noqa: E501

        # Authentication setting
        auth_settings = ["oauth2"]  # noqa: E501

        response_types_map = {}

        return self.api_client.call_api(
            "/crm/v3/lists/{listId}/memberships",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_types_map=response_types_map,
            auth_settings=auth_settings,
            async_req=local_var_params.get("async_req"),
            _return_http_data_only=local_var_params.get("_return_http_data_only"),  # noqa: E501
            _preload_content=local_var_params.get("_preload_content", True),
            _request_timeout=local_var_params.get("_request_timeout"),
            collection_formats=collection_formats,
            _request_auth=local_var_params.get("_request_auth"),
        )
