# Source code for api.authentication.v1.constrain

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

    @register_command(extending=('authentication','v1','constrain'))
    def constrain(customerID: list = None, functionID: list = None, function: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Request a constrained session (PUBLIC)
    This operation will spawn a new user session, where the active userspermissions are constrained to the specified subset of the active users permissions.In addition to returning the constrained session token, the new session will be set as cookies, overwriting any existing session cookies.

        :param list customerID: Set of customers the session should be valid for (default is all current customers). Cannot extend the current set of customers.
        :param list functionID: Set of functions/roles (by ID) the session should be granted (default is all current functions). Cannot extend the current set of functions.
        :param list function: Set of functions/roles (by name) the session should be granted (default is all current functions). Cannot extend the current set of functions.
        :returns: {"offset": 919, "limit": 51, "responseCode": 200, "count": 78, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Daughter class point television season late type.", "messageTemplate": "To city worker remain.", "field": "Job although force go behavior.", "parameter": {}, "timestamp": 1409064577}], "currentPage": 222, "size": 669}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/authentication/v1/constrain".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 customerID:
            body.update({"customerID": customerID})

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

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

        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