# coding: utf-8

"""
    Vidispine API

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

    The version of the OpenAPI document: 5.x
    Contact: info@vidispine.com
    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 vidispine.models import *
from vidispine.api_client import ApiClient
from vidispine.exceptions import (
    ApiTypeError,
    ApiValueError
)


class ConformApi(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 create_conform_job(self, conform_request_type, **kwargs):  # noqa: E501
        """Start a conform job  # noqa: E501

        Starts a new `CONFORM` job that creates a new item and one or more shapes that contains media according to the conform timeline.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.create_conform_job(conform_request_type, async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :param ConformRequestType conform_request_type: (required)
        :key list[str] jobmetadata: Additional information for the job task.
        :key str notification_data: Any additional data to include for notifications on this job.
        :key bool conform_metadata: - `true` (default) - Copy metadata from the source items, according to the timeline, to the resulting item.  - `false` - Do not copy metadata from the source items.
        :key str thumbnail_service: Identifies which thumbnail resource that should be used.
        :key list[str] tag: Comma-separated list of shape tags, that specify the desired output.
        :key list[str] source_tag: Comma-separated list of shape tags, that specify the shapes that should be used as inputs.
        :key str notification: The placeholder job notification to use for this job.
        :key bool create_thumbnails: - `true` - Creates thumbnails according to default transcoder rules.  - `false` (default) - No thumbnails will be created.
        :key str destination_item: An item id, to which the new new shape will be associated.
        :key str create_posters: A list of time codes to use for creating posters.
        :key str original: If specified, should be one of the tags specified in the tag parameter.  Specifies that the original shape tag will be reset to the shape created to this tag.
        :key str priority: The priority to assign to the job.
        :key str resource_id: The transcoder resource to use to execute the transcode.
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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: JobType.
                 If the method is called asynchronously, returns the request thread.
        :rtype: JobType or multiprocessing.pool.AsyncResult
        """
        kwargs['_return_http_data_only'] = True
        return self.create_conform_job_with_http_info(conform_request_type, **kwargs)  # noqa: E501

    def create_conform_job_with_http_info(self, conform_request_type, **kwargs):  # noqa: E501
        """Start a conform job  # noqa: E501

        Starts a new `CONFORM` job that creates a new item and one or more shapes that contains media according to the conform timeline.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_conform_job_with_http_info(conform_request_type, async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :param ConformRequestType conform_request_type: (required)
        :key list[str] jobmetadata: Additional information for the job task.
        :key str notification_data: Any additional data to include for notifications on this job.
        :key bool conform_metadata: - `true` (default) - Copy metadata from the source items, according to the timeline, to the resulting item.  - `false` - Do not copy metadata from the source items.
        :key str thumbnail_service: Identifies which thumbnail resource that should be used.
        :key list[str] tag: Comma-separated list of shape tags, that specify the desired output.
        :key list[str] source_tag: Comma-separated list of shape tags, that specify the shapes that should be used as inputs.
        :key str notification: The placeholder job notification to use for this job.
        :key bool create_thumbnails: - `true` - Creates thumbnails according to default transcoder rules.  - `false` (default) - No thumbnails will be created.
        :key str destination_item: An item id, to which the new new shape will be associated.
        :key str create_posters: A list of time codes to use for creating posters.
        :key str original: If specified, should be one of the tags specified in the tag parameter.  Specifies that the original shape tag will be reset to the shape created to this tag.
        :key str priority: The priority to assign to the job.
        :key str resource_id: The transcoder resource to use to execute the transcode.
        :key _return_http_data_only: response data without head status code
                                       and headers
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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: tuple(JobType, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['conform_request_type', 'jobmetadata', 'notification_data', 'conform_metadata', 'thumbnail_service', 'tag', 'source_tag', 'notification', 'create_thumbnails', 'destination_item', 'create_posters', 'original', 'priority', 'resource_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')

        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 create_conform_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'conform_request_type' is set
        if ('conform_request_type' not in local_var_params or
                local_var_params['conform_request_type'] is None):
            raise ApiValueError("Missing the required parameter `conform_request_type` when calling `create_conform_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'jobmetadata' in local_var_params:
            query_params.append(('jobmetadata', local_var_params['jobmetadata']))  # noqa: E501
            collection_formats['jobmetadata'] = 'multi'  # noqa: E501
        if 'notification_data' in local_var_params:
            query_params.append(('notificationData', local_var_params['notification_data']))  # noqa: E501
        if 'conform_metadata' in local_var_params:
            query_params.append(('conformMetadata', local_var_params['conform_metadata']))  # noqa: E501
        if 'thumbnail_service' in local_var_params:
            query_params.append(('thumbnailService', local_var_params['thumbnail_service']))  # noqa: E501
        if 'tag' in local_var_params:
            query_params.append(('tag', local_var_params['tag']))  # noqa: E501
            collection_formats['tag'] = 'csv'  # noqa: E501
        if 'source_tag' in local_var_params:
            query_params.append(('sourceTag', local_var_params['source_tag']))  # noqa: E501
            collection_formats['sourceTag'] = 'csv'  # noqa: E501
        if 'notification' in local_var_params:
            query_params.append(('notification', local_var_params['notification']))  # noqa: E501
        if 'create_thumbnails' in local_var_params:
            query_params.append(('createThumbnails', local_var_params['create_thumbnails']))  # noqa: E501
        if 'destination_item' in local_var_params:
            query_params.append(('destinationItem', local_var_params['destination_item']))  # noqa: E501
        if 'create_posters' in local_var_params:
            query_params.append(('createPosters', local_var_params['create_posters']))  # noqa: E501
        if 'original' in local_var_params:
            query_params.append(('original', local_var_params['original']))  # noqa: E501
        if 'priority' in local_var_params:
            query_params.append(('priority', local_var_params['priority']))  # noqa: E501
        if 'resource_id' in local_var_params:
            query_params.append(('resourceId', local_var_params['resource_id']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

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

        return self.api_client.call_api(
            '/conform', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JobType',  # noqa: E501
            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)
