# coding: utf-8

"""
    Alteryx Server API V3

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501

    OpenAPI spec version: 3
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from src.server_client.api_client import ApiClient


class SchedulesApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def schedules_create_schedule(self, contract, **kwargs):  # noqa: E501
        """Create a new schedule.  # noqa: E501

        If TimeZone is empty or skipped then all the datetime fields will be according to timezone UTC-0 and   if the TimeZone is given then all the datetime fields will be according to that timezone provided.  Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_create_schedule(contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateScheduleContract contract: See Data Type Model for iteration type contract structures. (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_create_schedule_with_http_info(contract, **kwargs)  # noqa: E501
        else:
            (data) = self.schedules_create_schedule_with_http_info(contract, **kwargs)  # noqa: E501
            return data

    def schedules_create_schedule_with_http_info(self, contract, **kwargs):  # noqa: E501
        """Create a new schedule.  # noqa: E501

        If TimeZone is empty or skipped then all the datetime fields will be according to timezone UTC-0 and   if the TimeZone is given then all the datetime fields will be according to that timezone provided.  Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_create_schedule_with_http_info(contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateScheduleContract contract: See Data Type Model for iteration type contract structures. (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['contract']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_create_schedule" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'contract' is set
        if self.api_client.client_side_validation and ('contract' not in params or
                                                       params['contract'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `contract` when calling `schedules_create_schedule`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'contract' in params:
            body_params = params['contract']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])  # noqa: E501

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

        return self.api_client.call_api(
            '/v3/schedules', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def schedules_delete_schedule(self, schedule_id, **kwargs):  # noqa: E501
        """Delete an existing schedule.  # noqa: E501

          # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_delete_schedule(schedule_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_delete_schedule_with_http_info(schedule_id, **kwargs)  # noqa: E501
        else:
            (data) = self.schedules_delete_schedule_with_http_info(schedule_id, **kwargs)  # noqa: E501
            return data

    def schedules_delete_schedule_with_http_info(self, schedule_id, **kwargs):  # noqa: E501
        """Delete an existing schedule.  # noqa: E501

          # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_delete_schedule_with_http_info(schedule_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['schedule_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_delete_schedule" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'schedule_id' is set
        if self.api_client.client_side_validation and ('schedule_id' not in params or
                                                       params['schedule_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `schedule_id` when calling `schedules_delete_schedule`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'schedule_id' in params:
            path_params['scheduleId'] = params['schedule_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/v3/schedules/{scheduleId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def schedules_get_schedule(self, schedule_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing schedule.  # noqa: E501

          # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_get_schedule(schedule_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_get_schedule_with_http_info(schedule_id, **kwargs)  # noqa: E501
        else:
            (data) = self.schedules_get_schedule_with_http_info(schedule_id, **kwargs)  # noqa: E501
            return data

    def schedules_get_schedule_with_http_info(self, schedule_id, **kwargs):  # noqa: E501
        """Retrieve details about an existing schedule.  # noqa: E501

          # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_get_schedule_with_http_info(schedule_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['schedule_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_get_schedule" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'schedule_id' is set
        if self.api_client.client_side_validation and ('schedule_id' not in params or
                                                       params['schedule_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `schedule_id` when calling `schedules_get_schedule`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'schedule_id' in params:
            path_params['scheduleId'] = params['schedule_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/v3/schedules/{scheduleId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ScheduleView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def schedules_get_schedules(self, **kwargs):  # noqa: E501
        """Retrieve all accessible schedule records.  # noqa: E501

        When filtering using RunsAfter and RunsBefore, you are limited to 45 days apart from each other.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_get_schedules(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str owner_id: Filter results for a specific owner.
        :param str workflow_id: Filter results for a specific workflow.
        :param datetime runs_after: Filters by whether a schedule will run after a given date, inclusive. Should be provided as UTC-0.
        :param datetime runs_before: Filters by whether a schedule will run after a given date, exclusive. Should be provided as UTC-0.
        :param str view: How much information about each schedule to return.
        :return: list[ReducedScheduleView]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_get_schedules_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.schedules_get_schedules_with_http_info(**kwargs)  # noqa: E501
            return data

    def schedules_get_schedules_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve all accessible schedule records.  # noqa: E501

        When filtering using RunsAfter and RunsBefore, you are limited to 45 days apart from each other.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_get_schedules_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str owner_id: Filter results for a specific owner.
        :param str workflow_id: Filter results for a specific workflow.
        :param datetime runs_after: Filters by whether a schedule will run after a given date, inclusive. Should be provided as UTC-0.
        :param datetime runs_before: Filters by whether a schedule will run after a given date, exclusive. Should be provided as UTC-0.
        :param str view: How much information about each schedule to return.
        :return: list[ReducedScheduleView]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['owner_id', 'workflow_id', 'runs_after', 'runs_before', 'view']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_get_schedules" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'owner_id' in params:
            query_params.append(('ownerId', params['owner_id']))  # noqa: E501
        if 'workflow_id' in params:
            query_params.append(('workflowId', params['workflow_id']))  # noqa: E501
        if 'runs_after' in params:
            query_params.append(('runsAfter', params['runs_after']))  # noqa: E501
        if 'runs_before' in params:
            query_params.append(('runsBefore', params['runs_before']))  # noqa: E501
        if 'view' in params:
            query_params.append(('view', params['view']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/v3/schedules', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[ReducedScheduleView]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def schedules_update_schedule(self, schedule_id, contract, **kwargs):  # noqa: E501
        """Update details of an existing schedule.  # noqa: E501

        If TimeZone is empty or skipped then all the datetime fields will be according to timezone UTC-0   and if the TimeZone is given then all the datetime fields will be according to that timezone provided.  Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_update_schedule(schedule_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :param UpdateScheduleContract contract:  (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_update_schedule_with_http_info(schedule_id, contract, **kwargs)  # noqa: E501
        else:
            (data) = self.schedules_update_schedule_with_http_info(schedule_id, contract, **kwargs)  # noqa: E501
            return data

    def schedules_update_schedule_with_http_info(self, schedule_id, contract, **kwargs):  # noqa: E501
        """Update details of an existing schedule.  # noqa: E501

        If TimeZone is empty or skipped then all the datetime fields will be according to timezone UTC-0   and if the TimeZone is given then all the datetime fields will be according to that timezone provided.  Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_update_schedule_with_http_info(schedule_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :param UpdateScheduleContract contract:  (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['schedule_id', 'contract']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_update_schedule" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'schedule_id' is set
        if self.api_client.client_side_validation and ('schedule_id' not in params or
                                                       params['schedule_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `schedule_id` when calling `schedules_update_schedule`")  # noqa: E501
        # verify the required parameter 'contract' is set
        if self.api_client.client_side_validation and ('contract' not in params or
                                                       params['contract'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `contract` when calling `schedules_update_schedule`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'schedule_id' in params:
            path_params['scheduleId'] = params['schedule_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'contract' in params:
            body_params = params['contract']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])  # noqa: E501

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

        return self.api_client.call_api(
            '/v3/schedules/{scheduleId}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ScheduleView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def schedules_update_schedule_patch(self, schedule_id, contract, **kwargs):  # noqa: E501
        """Update details of an existing schedule.  # noqa: E501

        Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_update_schedule_patch(schedule_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :param PatchScheduleContract contract:  (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.schedules_update_schedule_patch_with_http_info(schedule_id, contract, **kwargs)  # noqa: E501
        else:
            (data) = self.schedules_update_schedule_patch_with_http_info(schedule_id, contract, **kwargs)  # noqa: E501
            return data

    def schedules_update_schedule_patch_with_http_info(self, schedule_id, contract, **kwargs):  # noqa: E501
        """Update details of an existing schedule.  # noqa: E501

        Click https://help.alteryx.com/current/en/server/api-overview/alteryx-server-api-v3.html in order to view the list of valid timezones.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.schedules_update_schedule_patch_with_http_info(schedule_id, contract, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str schedule_id: Identifier for an existing schedule. (required)
        :param PatchScheduleContract contract:  (required)
        :return: ScheduleView
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['schedule_id', 'contract']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method schedules_update_schedule_patch" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'schedule_id' is set
        if self.api_client.client_side_validation and ('schedule_id' not in params or
                                                       params['schedule_id'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `schedule_id` when calling `schedules_update_schedule_patch`")  # noqa: E501
        # verify the required parameter 'contract' is set
        if self.api_client.client_side_validation and ('contract' not in params or
                                                       params['contract'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `contract` when calling `schedules_update_schedule_patch`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'schedule_id' in params:
            path_params['scheduleId'] = params['schedule_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'contract' in params:
            body_params = params['contract']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'text/json', 'application/xml', 'text/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])  # noqa: E501

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

        return self.api_client.call_api(
            '/v3/schedules/{scheduleId}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ScheduleView',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
