# coding: utf-8

"""
    Versatile Data Kit Control Service API

    The Data Jobs API of Versatile Data Kit Control Service. Data Jobs allows Data Engineers to implement automated pull ingestion (E in ELT) and batch data transformation into a database (T in ELT). See also https://github.com/vmware/versatile-data-kit/wiki/Introduction  The API has resource-oriented URLs, JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The API enables creating, deploying, managing and executing Data Jobs in the runtime environment.<br> <br> ![](https://github.com/vmware/versatile-data-kit/wiki/vdk-data-job-lifecycle-state-diagram.png) <br> The API reflects the usual Data Job Development lifecycle:<br> <li> Create a new data job (webhook to further configure the job, e.g authorize its creation, setup permissions, etc). <li> Download keytab. Develop and run the data job locally. <li> Deploy the data job in cloud runtime environment to run on a scheduled basis. <br><br> If Authentication is enabled, pass OAuth2 access token in HTTP header 'Authorization: Bearer [access-token-here]' (https://datatracker.ietf.org/doc/html/rfc6750). <br  The API promotes some best practices (inspired by https://12factor.net): <li> Explicitly declare and isolate dependencies. <li> Strict separation of configurations from code. Configurations vary substantially across deploys, code does not. <li> Separation between the build, release/deploy, and run stages. <li> Data Jobs are stateless and share-nothing processes. Any data that needs to be persisted must be stored in a stateful backing service (e.g IProperties). <li> Implementation is assumed to be atomic and idempotent - should be OK for a job to fail somewhere in the middle; subsequent restart should not cause data corruption. <li> Keep development, staging, and production as similar as possible. <br><br> <b>API Evolution</b><br> In the following sections, there are some terms that have a special meaning in the context of the APIs. <br><br> <li> <i>Stable</i> - The implementation of the API has been battle-tested (has been in production for some time).                      The API is a subject to semantic versioning model and will follow deprecation policy. <li> <i>Experimental</i> - May disappear without notice and is not a subject to semantic versioning.                            Implementation of the API is not considered stable nor well tested.                            Generally this is given to clients to experiment within testing environment. Must not be used in production. <li> <i>Deprecated</i> - API is expected to be removed within next one or two major version upgrade.                          The deprecation notice/comment will say when the API will be removed and what alternatives should be used instead.   # noqa: E501

    The version of the OpenAPI document: 1.0
    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 taurus_datajob_api.api_client import ApiClient
from taurus_datajob_api.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class DataJobsPropertiesApi(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 data_job_properties_read(self, team_name, job_name, deployment_id, **kwargs):  # noqa: E501
        """Get Data Job properties.  # noqa: E501

        <i>(Introduced in v1.0)</i>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.data_job_properties_read(team_name, job_name, deployment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str team_name: Team Name (required)
        :param str job_name: Data Job Name. (required)
        :param str deployment_id: Data job deployment id. (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :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: dict(str, object)
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.data_job_properties_read_with_http_info(team_name, job_name, deployment_id, **kwargs)  # noqa: E501

    def data_job_properties_read_with_http_info(self, team_name, job_name, deployment_id, **kwargs):  # noqa: E501
        """Get Data Job properties.  # noqa: E501

        <i>(Introduced in v1.0)</i>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.data_job_properties_read_with_http_info(team_name, job_name, deployment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str team_name: Team Name (required)
        :param str job_name: Data Job Name. (required)
        :param str deployment_id: Data job deployment id. (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :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: tuple(dict(str, object), status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'team_name',
            'job_name',
            'deployment_id'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 data_job_properties_read" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'team_name' is set
        if self.api_client.client_side_validation and ('team_name' not in local_var_params or  # noqa: E501
                                                        local_var_params['team_name'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `team_name` when calling `data_job_properties_read`")  # noqa: E501
        # verify the required parameter 'job_name' is set
        if self.api_client.client_side_validation and ('job_name' not in local_var_params or  # noqa: E501
                                                        local_var_params['job_name'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `job_name` when calling `data_job_properties_read`")  # noqa: E501
        # verify the required parameter 'deployment_id' is set
        if self.api_client.client_side_validation and ('deployment_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['deployment_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `deployment_id` when calling `data_job_properties_read`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'team_name' in local_var_params:
            path_params['team_name'] = local_var_params['team_name']  # noqa: E501
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']  # noqa: E501
        if 'deployment_id' in local_var_params:
            path_params['deployment_id'] = local_var_params['deployment_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'])  # noqa: E501

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

        return self.api_client.call_api(
            '/data-jobs/for-team/{team_name}/jobs/{job_name}/deployments/{deployment_id}/properties', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='dict(str, object)',  # 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)

    def data_job_properties_update(self, team_name, job_name, deployment_id, request_body, **kwargs):  # noqa: E501
        """Update Data Job properties.  # noqa: E501

        <i>(Introduced in v1.0)</i>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.data_job_properties_update(team_name, job_name, deployment_id, request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str team_name: Team Name (required)
        :param str job_name: Data Job Name. (required)
        :param str deployment_id: Data job deployment id. (required)
        :param dict(str, object) request_body: (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.data_job_properties_update_with_http_info(team_name, job_name, deployment_id, request_body, **kwargs)  # noqa: E501

    def data_job_properties_update_with_http_info(self, team_name, job_name, deployment_id, request_body, **kwargs):  # noqa: E501
        """Update Data Job properties.  # noqa: E501

        <i>(Introduced in v1.0)</i>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.data_job_properties_update_with_http_info(team_name, job_name, deployment_id, request_body, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str team_name: Team Name (required)
        :param str job_name: Data Job Name. (required)
        :param str deployment_id: Data job deployment id. (required)
        :param dict(str, object) request_body: (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :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: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'team_name',
            'job_name',
            'deployment_id',
            'request_body'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 data_job_properties_update" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'team_name' is set
        if self.api_client.client_side_validation and ('team_name' not in local_var_params or  # noqa: E501
                                                        local_var_params['team_name'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `team_name` when calling `data_job_properties_update`")  # noqa: E501
        # verify the required parameter 'job_name' is set
        if self.api_client.client_side_validation and ('job_name' not in local_var_params or  # noqa: E501
                                                        local_var_params['job_name'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `job_name` when calling `data_job_properties_update`")  # noqa: E501
        # verify the required parameter 'deployment_id' is set
        if self.api_client.client_side_validation and ('deployment_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['deployment_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `deployment_id` when calling `data_job_properties_update`")  # noqa: E501
        # verify the required parameter 'request_body' is set
        if self.api_client.client_side_validation and ('request_body' not in local_var_params or  # noqa: E501
                                                        local_var_params['request_body'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `request_body` when calling `data_job_properties_update`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'team_name' in local_var_params:
            path_params['team_name'] = local_var_params['team_name']  # noqa: E501
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']  # noqa: E501
        if 'deployment_id' in local_var_params:
            path_params['deployment_id'] = local_var_params['deployment_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'request_body' in local_var_params:
            body_params = local_var_params['request_body']
        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/data-jobs/for-team/{team_name}/jobs/{job_name}/deployments/{deployment_id}/properties', 'PUT',
            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=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)
