# Source code for api.cases.v2.servicesubscription

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

    @register_command(extending=('cases','v2','servicesubscription'))
    def list_subscriptions(customerID: list = None, service: list = None, offset: int = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """List service subscriptions (INTERNAL)

        :param list customerID: Limit result to specified list of customers (by id)
        :param list service: Limit result to specified list of services (by id or shortname)
        :param int offset: Skip a number of results
        :param int limit: Maximum number of returned results
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 846, "limit": 675, "responseCode": 200, "count": 272, "data": [{"id": "Whatever him to several.", "createdTimestamp": 1309801048, "createdByUser": {"id": 489, "customerID": 562, "userName": "peterherrera", "name": "David Murphy"}, "lastUpdatedTimestamp": 95224385, "lastUpdatedByUser": {"id": 700, "customerID": 475, "userName": "paul04", "name": "Veronica Barber"}, "flags": ["DELETED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Chair art day second attorney discover.", "messageTemplate": "Student analysis job know technology.", "field": "Enjoy despite common keep seem.", "parameter": {}, "timestamp": 1007698756}], "currentPage": 577, "size": 523}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/servicesubscription".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 offset:
            body.update({"offset": offset})

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

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

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

        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=('cases','v2','servicesubscription'))
    def add_customer_service_subscription(customer: str = None, service: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Subscribe a customer to a service (INTERNAL)

        :param str customer: Shortname or ID of customer to subscribe for
        :param str service: Shortname or ID of service to subscribe to
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 586, "limit": 978, "responseCode": 200, "count": 991, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Relationship modern argue actually then.", "messageTemplate": "Traditional real company think.", "field": "Process arrive them evidence smile three or.", "parameter": {}, "timestamp": 1090378908}], "currentPage": 606, "size": 277}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/servicesubscription".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 customer:
            body.update({"customer": customer})

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

        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=('cases','v2','servicesubscription'))
    def delete_customer_service_subscription(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Remove service subscription (INTERNAL)

        :param str id: Subscription ID
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 368, "limit": 147, "responseCode": 200, "count": 514, "metaData": {"additionalProperties": {}}, "messages": [{"message": "It specific recent agreement.", "messageTemplate": "Certain provide old heavy test cause first.", "field": "Game participant civil education in call reason least.", "parameter": {}, "timestamp": 133993615}], "currentPage": 361, "size": 960}
        """
        from requests import delete
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/cases/v2/servicesubscription/{id}".format(id=id)
        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 = delete(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