# Source code for api.users.v1.user

    """Autogenerated API"""
    import requests
    from argus_cli.plugin import register_command

    @register_command(extending=('users','v1','user'))
    def list_users(subjectID: list = None, offset: int = None, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Get user profiles (PUBLIC)

        :param list subjectID: IDs of users
        :param int offset: Offset results
        :param int limit: Limit results
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 849, "limit": 450, "responseCode": 200, "count": 440, "data": [{"id": 97, "customerID": 687, "userName": "arobinson", "name": "Margaret Green"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Possible above reflect.", "messageTemplate": "Unit scene civil sea give.", "field": "Record something follow above up.", "parameter": {}, "timestamp": 109259293}], "currentPage": 584, "size": 932}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user".format()
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if limit:
            body.update({"limit": limit})

        if subjectID:
            body.update({"subjectID": subjectID})

        if offset:
            body.update({"offset": offset})

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def find_users(limit: int = None, offset: int = None, includeFlags: int = None, excludeFlags: int = None, subCriteria: list = None, customerID: list = None, domain: list = None, type: str = None, subjectID: list = None, excludeSubjectID: list = None, parentID: list = None, ancestorID: list = None, get_aclAncestorID: list = None, get_aclCustomerID: list = None, excludeAncestorID: list = None, userName: list = None, email: list = None, mobile: list = None, searchString: str = None, languageID: list = None, requiredFunctionID: list = None, requiredFunctionCustomerID: int = None, includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False', requireAllFunctions: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Search user profiles (PUBLIC)

        :param int limit: Set this value to set max number of results. By default, no restriction on result set size.
        :param int offset: Set this value to skip the first (offset) objects. By default, return result from first object.
        :param int includeFlags: Only include objects which have includeFlags set.
        :param int excludeFlags: Exclude objects which have excludeFlags set.
        :param list subCriteria:
        :param list customerID: Restrict search to data belonging to specified customers.
        :param list domain:
        :param str type:
        :param list subjectID:
        :param list excludeSubjectID:
        :param list parentID:
        :param list ancestorID:
        :param list get_aclAncestorID:
        :param list get_aclCustomerID:
        :param list excludeAncestorID:
        :param list userName:
        :param list email:
        :param list mobile:
        :param str searchString:
        :param list languageID:
        :param list requiredFunctionID:
        :param int requiredFunctionCustomerID:
        :param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects.
        :param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded.
        :param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria).
        :param bool requireAllFunctions:
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :returns: {"offset": 753, "limit": 372, "responseCode": 200, "count": 568, "data": [{"id": 352, "customerID": 219, "userName": "veronica01", "name": "Mrs. Sharon Smith DDS"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Physical score another create first seek matter.", "messageTemplate": "Great budget laugh student place once position.", "field": "Travel our knowledge how usually.", "parameter": {}, "timestamp": 1170001423}], "currentPage": 437, "size": 113}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/search".format()
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if limit:
            body.update({"limit": limit})

        if offset:
            body.update({"offset": offset})

        if includeDeleted:
            body.update({"includeDeleted": includeDeleted})

        if includeFlags:
            body.update({"includeFlags": includeFlags})

        if excludeFlags:
            body.update({"excludeFlags": excludeFlags})

        if subCriteria:
            body.update({"subCriteria": subCriteria})

        if exclude:
            body.update({"exclude": exclude})

        if required:
            body.update({"required": required})

        if customerID:
            body.update({"customerID": customerID})

        if domain:
            body.update({"domain": domain})

        if type:
            body.update({"type": type})

        if subjectID:
            body.update({"subjectID": subjectID})

        if excludeSubjectID:
            body.update({"excludeSubjectID": excludeSubjectID})

        if parentID:
            body.update({"parentID": parentID})

        if ancestorID:
            body.update({"ancestorID": ancestorID})

        if get_aclAncestorID:
            body.update({"get_aclAncestorID": get_aclAncestorID})

        if get_aclCustomerID:
            body.update({"get_aclCustomerID": get_aclCustomerID})

        if excludeAncestorID:
            body.update({"excludeAncestorID": excludeAncestorID})

        if userName:
            body.update({"userName": userName})

        if email:
            body.update({"email": email})

        if mobile:
            body.update({"mobile": mobile})

        if searchString:
            body.update({"searchString": searchString})

        if languageID:
            body.update({"languageID": languageID})

        if requiredFunctionID:
            body.update({"requiredFunctionID": requiredFunctionID})

        if requiredFunctionCustomerID:
            body.update({"requiredFunctionCustomerID": requiredFunctionCustomerID})

        if requireAllFunctions:
            body.update({"requireAllFunctions": requireAllFunctions})

        response = post(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def get_profile(userId: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Get user profile by ID (PUBLIC)

        :param int userId: ID of user
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 292, "limit": 757, "responseCode": 200, "count": 817, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Create student natural program six attorney.", "messageTemplate": "Paper tree much where business cup.", "field": "Look stand baby manager knowledge dark market leg.", "parameter": {}, "timestamp": 1166105631}], "currentPage": 116, "size": 212}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userId}".format(userId=userId)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def get_user_customers(userId: int, offset: int = None, keywords: list = None, keywordField: list = None, limit: int = 25, keywordMatch: str = 'all',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List a user's customers. (DEV)

        :param int userId: ID of user
        :param int offset: Offset results
        :param list keywords: Search by keywords
        :param list keywordField: Set field strategy for keyword search
        :param int limit: Limit results
        :param str keywordMatch: Set match strategy for keyword search
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises UserNotFoundException: on 404
        :returns: {"offset": 610, "limit": 642, "responseCode": 200, "count": 815, "data": [{"id": 17, "name": "Elizabeth Mccullough", "shortName": "Finally pretty red."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Ball of computer few his between compare.", "messageTemplate": "Person list I fight trial still car.", "field": "Outside two because charge husband.", "parameter": {}, "timestamp": 1045205275}], "currentPage": 210, "size": 507}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userId}/customers".format(userId=userId)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if limit:
            body.update({"limit": limit})

        if keywordMatch:
            body.update({"keywordMatch": keywordMatch})

        if offset:
            body.update({"offset": offset})

        if keywords:
            body.update({"keywords": keywords})

        if keywordField:
            body.update({"keywordField": keywordField})

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def get_functions(userId: int, onlyRoles: bool = None, keywords: list = None, offset: int = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List a user's permission functions regardless of customer (PUBLIC)

        :param int userId: ID of user
        :param bool onlyRoles: Only return functions marked as roles
        :param list keywords: Filter functions by keywords on name and description
        :param int offset: Skip a number of functions
        :param int limit: Maximum number of returned functions
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises UserNotFoundException: on 404
        :returns: {"offset": 62, "limit": 550, "responseCode": 200, "count": 666, "data": [{"id": 31, "name": "Darrell Lopez", "description": "Behind let crime become.", "securityLevel": "ADMINISTRATIVE", "flags": ["ROLE"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "International before rock various single into able.", "messageTemplate": "Common wife western.", "field": "Significant design professional become hand.", "parameter": {}, "timestamp": 1036642439}], "currentPage": 64, "size": 467}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userId}/functions".format(userId=userId)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if offset:
            body.update({"offset": offset})

        if limit:
            body.update({"limit": limit})

        if onlyRoles:
            body.update({"onlyRoles": onlyRoles})

        if keywords:
            body.update({"keywords": keywords})

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def check_permission(userId: int, function: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Validate user permission to perform function (PUBLIC)

        :param int userId: ID of user
        :param str function: Function name
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises ForbiddenPermissionException: on 403
        :raises UserNotFoundException: on 404
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userId}/permission/{function}".format(userId=userId, function=function)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def update_profile_picture_for_user(userId: int, picture: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Upload and modify the user image (PUBLIC)

        :param int userId: ID of user to change image for
        :param str picture: Image data URL
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 320, "limit": 107, "responseCode": 200, "count": 660, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Bank staff clearly someone federal.", "messageTemplate": "Manager describe wrong rise recognize recently budget.", "field": "Child article seem sister shake stuff look.", "parameter": {}, "timestamp": 1153575697}], "currentPage": 25, "size": 233}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userId}/picture".format(userId=userId)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if picture:
            body.update({"picture": picture})

        response = put(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('users','v1','user'))
    def get_user_by_username(userName: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Get user profile by username (PUBLIC)

        :param str userName: Username
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 110, "limit": 468, "responseCode": 200, "count": 573, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Traditional coach in he.", "messageTemplate": "Answer its run tell.", "field": "Order west meet little.", "parameter": {}, "timestamp": 1299852476}], "currentPage": 957, "size": 602}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/user/{userName}".format(userName=userName)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response