# coding: utf-8

"""
    Corva API

    The Corva API is a powerful interface providing great flexibility and extensibility with Corva. Whether your needs are simple UI visualizations, data entry, replication/sync tasks, real-time stream processing, or complex machine learning CPU-intensive apps, the Corva API is the way to make it happen. Our concepts are split into three distinct silos: data apps, visualization apps, and a REST API

    The version of the OpenAPI document: v2.146.0
    Contact: support@corva.ai
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError

from typing_extensions import Annotated
from pydantic import Field, StrictFloat, StrictInt, StrictStr, conlist

from typing import List, Optional, Union

from corva_assets.models.asset import Asset

from corva_assets.api_client import ApiClient
from corva_assets.api_response import ApiResponse
from corva_assets.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class AssetsApi:
    """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) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_arguments
    def v2_assets_get(self, types : Annotated[Optional[StrictStr], Field(description="List of asset types")] = None, status : Annotated[Optional[StrictStr], Field(description="Search by asset status")] = None, visibility : Annotated[Optional[StrictStr], Field(description="Search by asset visibility")] = None, ids : Annotated[Optional[conlist(Union[StrictFloat, StrictInt])], Field(description="List of asset IDs to filter by")] = None, program : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by Program ID")] = None, parent_asset_id : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by parent asset ID")] = None, api_number : Annotated[Optional[StrictStr], Field(description="Search by API number or other well identifier")] = None, search : Annotated[Optional[StrictStr], Field(description="Search by asset ID, asset name, api_number or customer_well_id")] = None, start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by start time as a Unix timestamp")] = None, end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by end time as a Unix timestamp")] = None, long_start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, long_end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, lat_start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, lat_end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, company_id : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by Company ID")] = None, fields : Annotated[Optional[conlist(StrictStr)], Field(description="Respond with only the given list of fields, like asset.asset_type. See example response for fields.")] = None, per_page : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Number of items to list per page")] = None, sort : Annotated[Optional[StrictStr], Field(description="One or more fields to sort by. Prefix with a - for descending order. Ex: name,-last_active_at")] = None, order : Annotated[Optional[StrictStr], Field(description="A sorting direction")] = None, **kwargs) -> List[Asset]:  # noqa: E501
        """List assets  # noqa: E501

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

        >>> thread = api.v2_assets_get(types, status, visibility, ids, program, parent_asset_id, api_number, search, start, end, long_start, long_end, lat_start, lat_end, company_id, fields, per_page, sort, order, async_req=True)
        >>> result = thread.get()

        :param types: List of asset types
        :type types: str
        :param status: Search by asset status
        :type status: str
        :param visibility: Search by asset visibility
        :type visibility: str
        :param ids: List of asset IDs to filter by
        :type ids: List[float]
        :param program: Search by Program ID
        :type program: float
        :param parent_asset_id: Search by parent asset ID
        :type parent_asset_id: float
        :param api_number: Search by API number or other well identifier
        :type api_number: str
        :param search: Search by asset ID, asset name, api_number or customer_well_id
        :type search: str
        :param start: Search by start time as a Unix timestamp
        :type start: float
        :param end: Search by end time as a Unix timestamp
        :type end: float
        :param long_start: Search by lon_lat coordinate area
        :type long_start: float
        :param long_end: Search by lon_lat coordinate area
        :type long_end: float
        :param lat_start: Search by lon_lat coordinate area
        :type lat_start: float
        :param lat_end: Search by lon_lat coordinate area
        :type lat_end: float
        :param company_id: Search by Company ID
        :type company_id: float
        :param fields: Respond with only the given list of fields, like asset.asset_type. See example response for fields.
        :type fields: List[str]
        :param per_page: Number of items to list per page
        :type per_page: float
        :param sort: One or more fields to sort by. Prefix with a - for descending order. Ex: name,-last_active_at
        :type sort: str
        :param order: A sorting direction
        :type order: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: 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: List[Asset]
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the v2_assets_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.v2_assets_get_with_http_info(types, status, visibility, ids, program, parent_asset_id, api_number, search, start, end, long_start, long_end, lat_start, lat_end, company_id, fields, per_page, sort, order, **kwargs)  # noqa: E501

    @validate_arguments
    def v2_assets_get_with_http_info(self, types : Annotated[Optional[StrictStr], Field(description="List of asset types")] = None, status : Annotated[Optional[StrictStr], Field(description="Search by asset status")] = None, visibility : Annotated[Optional[StrictStr], Field(description="Search by asset visibility")] = None, ids : Annotated[Optional[conlist(Union[StrictFloat, StrictInt])], Field(description="List of asset IDs to filter by")] = None, program : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by Program ID")] = None, parent_asset_id : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by parent asset ID")] = None, api_number : Annotated[Optional[StrictStr], Field(description="Search by API number or other well identifier")] = None, search : Annotated[Optional[StrictStr], Field(description="Search by asset ID, asset name, api_number or customer_well_id")] = None, start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by start time as a Unix timestamp")] = None, end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by end time as a Unix timestamp")] = None, long_start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, long_end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, lat_start : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, lat_end : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by lon_lat coordinate area")] = None, company_id : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Search by Company ID")] = None, fields : Annotated[Optional[conlist(StrictStr)], Field(description="Respond with only the given list of fields, like asset.asset_type. See example response for fields.")] = None, per_page : Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Number of items to list per page")] = None, sort : Annotated[Optional[StrictStr], Field(description="One or more fields to sort by. Prefix with a - for descending order. Ex: name,-last_active_at")] = None, order : Annotated[Optional[StrictStr], Field(description="A sorting direction")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List assets  # noqa: E501

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

        >>> thread = api.v2_assets_get_with_http_info(types, status, visibility, ids, program, parent_asset_id, api_number, search, start, end, long_start, long_end, lat_start, lat_end, company_id, fields, per_page, sort, order, async_req=True)
        >>> result = thread.get()

        :param types: List of asset types
        :type types: str
        :param status: Search by asset status
        :type status: str
        :param visibility: Search by asset visibility
        :type visibility: str
        :param ids: List of asset IDs to filter by
        :type ids: List[float]
        :param program: Search by Program ID
        :type program: float
        :param parent_asset_id: Search by parent asset ID
        :type parent_asset_id: float
        :param api_number: Search by API number or other well identifier
        :type api_number: str
        :param search: Search by asset ID, asset name, api_number or customer_well_id
        :type search: str
        :param start: Search by start time as a Unix timestamp
        :type start: float
        :param end: Search by end time as a Unix timestamp
        :type end: float
        :param long_start: Search by lon_lat coordinate area
        :type long_start: float
        :param long_end: Search by lon_lat coordinate area
        :type long_end: float
        :param lat_start: Search by lon_lat coordinate area
        :type lat_start: float
        :param lat_end: Search by lon_lat coordinate area
        :type lat_end: float
        :param company_id: Search by Company ID
        :type company_id: float
        :param fields: Respond with only the given list of fields, like asset.asset_type. See example response for fields.
        :type fields: List[str]
        :param per_page: Number of items to list per page
        :type per_page: float
        :param sort: One or more fields to sort by. Prefix with a - for descending order. Ex: name,-last_active_at
        :type sort: str
        :param order: A sorting direction
        :type order: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: 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(List[Asset], status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'types',
            'status',
            'visibility',
            'ids',
            'program',
            'parent_asset_id',
            'api_number',
            'search',
            'start',
            'end',
            'long_start',
            'long_end',
            'lat_start',
            'lat_end',
            'company_id',
            'fields',
            'per_page',
            'sort',
            'order'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method v2_assets_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('types') is not None:  # noqa: E501
            _query_params.append(('types', _params['types']))

        if _params.get('status') is not None:  # noqa: E501
            _query_params.append(('status', _params['status']))

        if _params.get('visibility') is not None:  # noqa: E501
            _query_params.append(('visibility', _params['visibility']))

        if _params.get('ids') is not None:  # noqa: E501
            _query_params.append(('ids', _params['ids']))
            _collection_formats['ids'] = 'csv'

        if _params.get('program') is not None:  # noqa: E501
            _query_params.append(('program', _params['program']))

        if _params.get('parent_asset_id') is not None:  # noqa: E501
            _query_params.append(('parent_asset_id', _params['parent_asset_id']))

        if _params.get('api_number') is not None:  # noqa: E501
            _query_params.append(('api_number', _params['api_number']))

        if _params.get('search') is not None:  # noqa: E501
            _query_params.append(('search', _params['search']))

        if _params.get('start') is not None:  # noqa: E501
            _query_params.append(('start', _params['start']))

        if _params.get('end') is not None:  # noqa: E501
            _query_params.append(('end', _params['end']))

        if _params.get('long_start') is not None:  # noqa: E501
            _query_params.append(('long_start', _params['long_start']))

        if _params.get('long_end') is not None:  # noqa: E501
            _query_params.append(('long_end', _params['long_end']))

        if _params.get('lat_start') is not None:  # noqa: E501
            _query_params.append(('lat_start', _params['lat_start']))

        if _params.get('lat_end') is not None:  # noqa: E501
            _query_params.append(('lat_end', _params['lat_end']))

        if _params.get('company_id') is not None:  # noqa: E501
            _query_params.append(('company_id', _params['company_id']))

        if _params.get('fields') is not None:  # noqa: E501
            _query_params.append(('fields', _params['fields']))
            _collection_formats['fields'] = 'csv'

        if _params.get('per_page') is not None:  # noqa: E501
            _query_params.append(('per_page', _params['per_page']))

        if _params.get('sort') is not None:  # noqa: E501
            _query_params.append(('sort', _params['sort']))

        if _params.get('order') is not None:  # noqa: E501
            _query_params.append(('order', _params['order']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['api_key']  # noqa: E501

        _response_types_map = {
            '200': "List[Asset]",
            '401': "AuthenticationError",
            '403': "AuthorizationError",
            '404': "NotFoundError",
        }

        return self.api_client.call_api(
            '/v2/assets', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    def v2_assets_id_get(self, id : Annotated[Union[StrictFloat, StrictInt], Field(..., description="Asset ID")], fields : Annotated[Optional[conlist(StrictStr)], Field(description="Respond with only the given list of fields, like asset.asset_type")] = None, **kwargs) -> Asset:  # noqa: E501
        """Get asset by ID  # noqa: E501

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

        >>> thread = api.v2_assets_id_get(id, fields, async_req=True)
        >>> result = thread.get()

        :param id: Asset ID (required)
        :type id: float
        :param fields: Respond with only the given list of fields, like asset.asset_type
        :type fields: List[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: 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: Asset
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the v2_assets_id_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return self.v2_assets_id_get_with_http_info(id, fields, **kwargs)  # noqa: E501

    @validate_arguments
    def v2_assets_id_get_with_http_info(self, id : Annotated[Union[StrictFloat, StrictInt], Field(..., description="Asset ID")], fields : Annotated[Optional[conlist(StrictStr)], Field(description="Respond with only the given list of fields, like asset.asset_type")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get asset by ID  # noqa: E501

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

        >>> thread = api.v2_assets_id_get_with_http_info(id, fields, async_req=True)
        >>> result = thread.get()

        :param id: Asset ID (required)
        :type id: float
        :param fields: Respond with only the given list of fields, like asset.asset_type
        :type fields: List[str]
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: 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(Asset, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'id',
            'fields'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method v2_assets_id_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['id']:
            _path_params['id'] = _params['id']


        # process the query parameters
        _query_params = []
        if _params.get('fields') is not None:  # noqa: E501
            _query_params.append(('fields', _params['fields']))
            _collection_formats['fields'] = 'csv'

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['api_key']  # noqa: E501

        _response_types_map = {
            '200': "Asset",
            '401': "AuthenticationError",
            '403': "AuthorizationError",
            '404': "NotFoundError",
        }

        return self.api_client.call_api(
            '/v2/assets/{id}', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get('async_req'),
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
