# coding: utf-8

"""
    Mentortools Access Server

    Mentortools service for Access Packages with lazy access resolution

    The version of the OpenAPI document: 0.1.0
    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 import overload, Optional, Union, Awaitable

from pydantic import StrictBool, StrictInt, conint

from typing import Any, Dict, Optional

from access_server_connector.models.grant_in import GrantIn
from access_server_connector.models.wrapped_response_id_out import WrappedResponseIdOut
from access_server_connector.models.wrapped_response_int import WrappedResponseInt
from access_server_connector.models.wrapped_response_list_owned_package_out import WrappedResponseListOwnedPackageOut
from access_server_connector.models.wrapped_response_list_ownership_reason_out import WrappedResponseListOwnershipReasonOut
from access_server_connector.models.wrapped_response_list_package_member_out import WrappedResponseListPackageMemberOut
from access_server_connector.models.wrapped_response_list_portal_ownership_out import WrappedResponseListPortalOwnershipOut

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


class OwnershipApi:
    """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
    async def count_portal_members_v1_ownership_members_count_get(self, is_active : Optional[StrictBool] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Count ALL members holding any package (distinct)  # noqa: E501

        Query: is_active?. Distinct members (for pagination of /members).  # noqa: E501

        :param is_active:
        :type is_active: bool
        :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: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the count_portal_members_v1_ownership_members_count_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.count_portal_members_v1_ownership_members_count_get_with_http_info(is_active, **kwargs)  # noqa: E501

    @validate_arguments
    async def count_portal_members_v1_ownership_members_count_get_with_http_info(self, is_active : Optional[StrictBool] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Count ALL members holding any package (distinct)  # noqa: E501

        Query: is_active?. Distinct members (for pagination of /members).  # noqa: E501

        :param is_active:
        :type is_active: bool
        :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(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'is_active'
        ]
        _all_params.extend(
            [
                '_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 count_portal_members_v1_ownership_members_count_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('is_active') is not None:  # noqa: E501
            _query_params.append(('is_active', _params['is_active']))

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/members/count', '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,
            _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
    async def count_portal_ownerships_v1_ownership_reasons_count_get(self, access_package_id : Optional[StrictInt] = None, member_id : Optional[StrictInt] = None, kind : Optional[Any] = None, is_active : Optional[StrictBool] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Count ALL grants across the portal's packages  # noqa: E501

        Query: access_package_id?, member_id?, kind?, is_active?. Grants, not distinct members — see /members/count for people.  # noqa: E501

        :param access_package_id:
        :type access_package_id: int
        :param member_id:
        :type member_id: int
        :param kind:
        :type kind: ReasonKind
        :param is_active:
        :type is_active: bool
        :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: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the count_portal_ownerships_v1_ownership_reasons_count_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.count_portal_ownerships_v1_ownership_reasons_count_get_with_http_info(access_package_id, member_id, kind, is_active, **kwargs)  # noqa: E501

    @validate_arguments
    async def count_portal_ownerships_v1_ownership_reasons_count_get_with_http_info(self, access_package_id : Optional[StrictInt] = None, member_id : Optional[StrictInt] = None, kind : Optional[Any] = None, is_active : Optional[StrictBool] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Count ALL grants across the portal's packages  # noqa: E501

        Query: access_package_id?, member_id?, kind?, is_active?. Grants, not distinct members — see /members/count for people.  # noqa: E501

        :param access_package_id:
        :type access_package_id: int
        :param member_id:
        :type member_id: int
        :param kind:
        :type kind: ReasonKind
        :param is_active:
        :type is_active: bool
        :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(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'access_package_id',
            'member_id',
            'kind',
            'is_active'
        ]
        _all_params.extend(
            [
                '_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 count_portal_ownerships_v1_ownership_reasons_count_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('access_package_id') is not None:  # noqa: E501
            _query_params.append(('access_package_id', _params['access_package_id']))

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

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

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

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/reasons/count', '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,
            _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
    async def deactivate_v1_ownership_reasons_reason_id_deactivate_post(self, reason_id : StrictInt, body : Dict[str, Any], **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Deactivate (revoke) an ownership reason  # noqa: E501


        :param reason_id: (required)
        :type reason_id: int
        :param body: (required)
        :type body: object
        :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: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the deactivate_v1_ownership_reasons_reason_id_deactivate_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.deactivate_v1_ownership_reasons_reason_id_deactivate_post_with_http_info(reason_id, body, **kwargs)  # noqa: E501

    @validate_arguments
    async def deactivate_v1_ownership_reasons_reason_id_deactivate_post_with_http_info(self, reason_id : StrictInt, body : Dict[str, Any], **kwargs) -> ApiResponse:  # noqa: E501
        """Deactivate (revoke) an ownership reason  # noqa: E501


        :param reason_id: (required)
        :type reason_id: int
        :param body: (required)
        :type body: object
        :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(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'reason_id',
            'body'
        ]
        _all_params.extend(
            [
                '_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 deactivate_v1_ownership_reasons_reason_id_deactivate_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['reason_id'] is not None:
            _path_params['reason_id'] = _params['reason_id']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['body'] is not None:
            _body_params = _params['body']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/reasons/{reason_id}/deactivate', 'POST',
            _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,
            _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
    async def grant_v1_ownership_grant_post(self, grant_in : GrantIn, **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Manually grant an access package  # noqa: E501


        :param grant_in: (required)
        :type grant_in: GrantIn
        :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: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the grant_v1_ownership_grant_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.grant_v1_ownership_grant_post_with_http_info(grant_in, **kwargs)  # noqa: E501

    @validate_arguments
    async def grant_v1_ownership_grant_post_with_http_info(self, grant_in : GrantIn, **kwargs) -> ApiResponse:  # noqa: E501
        """Manually grant an access package  # noqa: E501


        :param grant_in: (required)
        :type grant_in: GrantIn
        :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(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'grant_in'
        ]
        _all_params.extend(
            [
                '_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 grant_v1_ownership_grant_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['grant_in'] is not None:
            _body_params = _params['grant_in']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/grant', 'POST',
            _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,
            _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
    async def member_packages_count_v1_ownership_members_member_id_packages_count_get(self, member_id : StrictInt, is_active : Optional[StrictBool] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Count the access packages a member owns  # noqa: E501

        Query: portal_id, is_active?. Total matching packages (for pagination).  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :param is_active:
        :type is_active: bool
        :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: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the member_packages_count_v1_ownership_members_member_id_packages_count_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.member_packages_count_v1_ownership_members_member_id_packages_count_get_with_http_info(member_id, is_active, **kwargs)  # noqa: E501

    @validate_arguments
    async def member_packages_count_v1_ownership_members_member_id_packages_count_get_with_http_info(self, member_id : StrictInt, is_active : Optional[StrictBool] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Count the access packages a member owns  # noqa: E501

        Query: portal_id, is_active?. Total matching packages (for pagination).  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :param is_active:
        :type is_active: bool
        :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(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'member_id',
            'is_active'
        ]
        _all_params.extend(
            [
                '_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 member_packages_count_v1_ownership_members_member_id_packages_count_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['member_id'] is not None:
            _path_params['member_id'] = _params['member_id']


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

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/members/{member_id}/packages/count', '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,
            _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
    async def member_packages_v1_ownership_members_member_id_packages_get(self, member_id : StrictInt, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> WrappedResponseListOwnedPackageOut:  # noqa: E501
        """List the access packages a member owns (paginated)  # noqa: E501

        Query: portal_id, is_active?, limit, offset. is_active: omit = all, true = currently-owned only, false = only lapsed/revoked. Use …/packages/count for the total.  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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: WrappedResponseListOwnedPackageOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the member_packages_v1_ownership_members_member_id_packages_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.member_packages_v1_ownership_members_member_id_packages_get_with_http_info(member_id, is_active, limit, offset, **kwargs)  # noqa: E501

    @validate_arguments
    async def member_packages_v1_ownership_members_member_id_packages_get_with_http_info(self, member_id : StrictInt, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List the access packages a member owns (paginated)  # noqa: E501

        Query: portal_id, is_active?, limit, offset. is_active: omit = all, true = currently-owned only, false = only lapsed/revoked. Use …/packages/count for the total.  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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(WrappedResponseListOwnedPackageOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'member_id',
            'is_active',
            'limit',
            'offset'
        ]
        _all_params.extend(
            [
                '_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 member_packages_v1_ownership_members_member_id_packages_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['member_id'] is not None:
            _path_params['member_id'] = _params['member_id']


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

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

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

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListOwnedPackageOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/members/{member_id}/packages', '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,
            _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
    async def ownership_list_v1_ownership_members_member_id_reasons_get(self, member_id : StrictInt, **kwargs) -> WrappedResponseListOwnershipReasonOut:  # noqa: E501
        """List a member's ownership reasons  # noqa: E501

        Query: portal_id.  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :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: WrappedResponseListOwnershipReasonOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the ownership_list_v1_ownership_members_member_id_reasons_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.ownership_list_v1_ownership_members_member_id_reasons_get_with_http_info(member_id, **kwargs)  # noqa: E501

    @validate_arguments
    async def ownership_list_v1_ownership_members_member_id_reasons_get_with_http_info(self, member_id : StrictInt, **kwargs) -> ApiResponse:  # noqa: E501
        """List a member's ownership reasons  # noqa: E501

        Query: portal_id.  # noqa: E501

        :param member_id: (required)
        :type member_id: int
        :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(WrappedResponseListOwnershipReasonOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'member_id'
        ]
        _all_params.extend(
            [
                '_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 ownership_list_v1_ownership_members_member_id_reasons_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['member_id'] is not None:
            _path_params['member_id'] = _params['member_id']


        # process the query parameters
        _query_params = []
        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListOwnershipReasonOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/members/{member_id}/reasons', '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,
            _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
    async def portal_members_v1_ownership_members_get(self, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> WrappedResponseListPackageMemberOut:  # noqa: E501
        """List ALL members holding any package (paginated) — the members page  # noqa: E501

        Portal-wide deduped roster: one row per member with every grant (across all packages) nested; limit/offset page MEMBERS. Query: is_active? (omit = all; true = members with an effective grant; false = only dead), limit, offset. Use /members/count for the total.  # noqa: E501

        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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: WrappedResponseListPackageMemberOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the portal_members_v1_ownership_members_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.portal_members_v1_ownership_members_get_with_http_info(is_active, limit, offset, **kwargs)  # noqa: E501

    @validate_arguments
    async def portal_members_v1_ownership_members_get_with_http_info(self, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List ALL members holding any package (paginated) — the members page  # noqa: E501

        Portal-wide deduped roster: one row per member with every grant (across all packages) nested; limit/offset page MEMBERS. Query: is_active? (omit = all; true = members with an effective grant; false = only dead), limit, offset. Use /members/count for the total.  # noqa: E501

        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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(WrappedResponseListPackageMemberOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'is_active',
            'limit',
            'offset'
        ]
        _all_params.extend(
            [
                '_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 portal_members_v1_ownership_members_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('is_active') is not None:  # noqa: E501
            _query_params.append(('is_active', _params['is_active']))

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

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

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListPackageMemberOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/members', '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,
            _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
    async def portal_ownerships_v1_ownership_reasons_get(self, access_package_id : Optional[StrictInt] = None, member_id : Optional[StrictInt] = None, kind : Optional[Any] = None, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> WrappedResponseListPortalOwnershipOut:  # noqa: E501
        """List ALL grants across the portal's packages (paginated) — the orders page  # noqa: E501

        Portal-wide grant ledger, newest first, each row with its package_title. Query: access_package_id?, member_id?, kind?, is_active? (omit = all; true = effective only; false = only expired/revoked/dead), limit, offset. Use /reasons/count for the total.  # noqa: E501

        :param access_package_id:
        :type access_package_id: int
        :param member_id:
        :type member_id: int
        :param kind:
        :type kind: ReasonKind
        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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: WrappedResponseListPortalOwnershipOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the portal_ownerships_v1_ownership_reasons_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.portal_ownerships_v1_ownership_reasons_get_with_http_info(access_package_id, member_id, kind, is_active, limit, offset, **kwargs)  # noqa: E501

    @validate_arguments
    async def portal_ownerships_v1_ownership_reasons_get_with_http_info(self, access_package_id : Optional[StrictInt] = None, member_id : Optional[StrictInt] = None, kind : Optional[Any] = None, is_active : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List ALL grants across the portal's packages (paginated) — the orders page  # noqa: E501

        Portal-wide grant ledger, newest first, each row with its package_title. Query: access_package_id?, member_id?, kind?, is_active? (omit = all; true = effective only; false = only expired/revoked/dead), limit, offset. Use /reasons/count for the total.  # noqa: E501

        :param access_package_id:
        :type access_package_id: int
        :param member_id:
        :type member_id: int
        :param kind:
        :type kind: ReasonKind
        :param is_active:
        :type is_active: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :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(WrappedResponseListPortalOwnershipOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'access_package_id',
            'member_id',
            'kind',
            'is_active',
            'limit',
            'offset'
        ]
        _all_params.extend(
            [
                '_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 portal_ownerships_v1_ownership_reasons_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('access_package_id') is not None:  # noqa: E501
            _query_params.append(('access_package_id', _params['access_package_id']))

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

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

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

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

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

        # 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 = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListPortalOwnershipOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/ownership/reasons', '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,
            _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'))
