# Code generated by Lark OpenAPI.

import io
from typing import Any, Optional, Union, Dict, List, Set, IO, Callable, Type
from lark_oapi.core.const import UTF_8, CONTENT_TYPE, APPLICATION_JSON
from lark_oapi.core import JSON
from lark_oapi.core.token import verify
from lark_oapi.core.http import Transport
from lark_oapi.core.model import Config, RequestOption, RawResponse
from lark_oapi.core.utils import Files
from requests_toolbelt import MultipartEncoder
from ..model.del_report_archive_rule_request import DelReportArchiveRuleRequest
from ..model.del_report_archive_rule_response import DelReportArchiveRuleResponse
from ..model.list_archive_rule_request import ListArchiveRuleRequest
from ..model.list_archive_rule_response import ListArchiveRuleResponse
from ..model.upload_report_archive_rule_request import UploadReportArchiveRuleRequest
from ..model.upload_report_archive_rule_response import UploadReportArchiveRuleResponse
from ..model.user_stats_fields_query_archive_rule_request import UserStatsFieldsQueryArchiveRuleRequest
from ..model.user_stats_fields_query_archive_rule_response import UserStatsFieldsQueryArchiveRuleResponse


class ArchiveRule(object):
    def __init__(self, config: Config) -> None:
        self.config: Config = config

    def del_report(self, request: DelReportArchiveRuleRequest,
                   option: Optional[RequestOption] = None) -> DelReportArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: DelReportArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8), DelReportArchiveRuleResponse)
        response.raw = resp

        return response

    async def adel_report(self, request: DelReportArchiveRuleRequest,
                          option: Optional[RequestOption] = None) -> DelReportArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: DelReportArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8), DelReportArchiveRuleResponse)
        response.raw = resp

        return response

    def list(self, request: ListArchiveRuleRequest, option: Optional[RequestOption] = None) -> ListArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: ListArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8), ListArchiveRuleResponse)
        response.raw = resp

        return response

    async def alist(self, request: ListArchiveRuleRequest,
                    option: Optional[RequestOption] = None) -> ListArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: ListArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8), ListArchiveRuleResponse)
        response.raw = resp

        return response

    def upload_report(self, request: UploadReportArchiveRuleRequest,
                      option: Optional[RequestOption] = None) -> UploadReportArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: UploadReportArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                   UploadReportArchiveRuleResponse)
        response.raw = resp

        return response

    async def aupload_report(self, request: UploadReportArchiveRuleRequest,
                             option: Optional[RequestOption] = None) -> UploadReportArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: UploadReportArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                   UploadReportArchiveRuleResponse)
        response.raw = resp

        return response

    def user_stats_fields_query(self, request: UserStatsFieldsQueryArchiveRuleRequest,
                                option: Optional[RequestOption] = None) -> UserStatsFieldsQueryArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 添加 content-type
        if request.body is not None:
            option.headers[CONTENT_TYPE] = f"{APPLICATION_JSON}; charset=utf-8"

        # 发起请求
        resp: RawResponse = Transport.execute(self.config, request, option)

        # 反序列化
        response: UserStatsFieldsQueryArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                           UserStatsFieldsQueryArchiveRuleResponse)
        response.raw = resp

        return response

    async def auser_stats_fields_query(self, request: UserStatsFieldsQueryArchiveRuleRequest, option: Optional[
        RequestOption] = None) -> UserStatsFieldsQueryArchiveRuleResponse:
        if option is None:
            option = RequestOption()

        # 鉴权、获取 token
        verify(self.config, request, option)

        # 发起请求
        resp: RawResponse = await Transport.aexecute(self.config, request, option)

        # 反序列化
        response: UserStatsFieldsQueryArchiveRuleResponse = JSON.unmarshal(str(resp.content, UTF_8),
                                                                           UserStatsFieldsQueryArchiveRuleResponse)
        response.raw = resp

        return response
