Source code for api.customers.v1.customer

"""Autogenerated API"""

from argus_cli.plugin import register_command



[docs]@register_command(extending=("customers","v1","customer")) def list_customers( parentID: list = None, service: list = None, keywords: list = None, keywordField: list = None, sortBy: list = None, offset: int = None, limit: int = 25, keywordMatch: str = "all", json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns customers defined by query parameters (PUBLIC) :param list parentID: Search by parentID :param list service: Search by services :param list keywords: Search by keywords :param list keywordField: Set field strategy for keyword search :param list sortBy: Sort search result :param int offset: Skip a number of results :param int limit: Maximum number of returned results :param str keywordMatch: Set match strategy for keyword search :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 240, 'limit': 811, 'responseCode': 200, 'count': 817, 'data': [{'id': 942, 'flags': ['INITIAL_TUNING'], 'name': 'Cynthia Lawson', 'shortName': 'Year detail spend sometimes prevent number.', 'properties': {'additionalProperties': 'Matter fly trip success year true.'}, 'services': [{'id': 959, 'name': 'Robert Palmer', 'description': 'Last course article happy exactly.'}], 'createdByUser': {'id': 453, 'customerID': 146, 'userName': 'coffeyandrew', 'name': 'Ralph Mendoza'}, 'createdTimestamp': 633428033, 'lastUpdatedByUser': {'id': 224, 'customerID': 36, 'userName': 'rebecca97', 'name': 'Carla Pugh'}, 'accountManager': {'id': 489, 'customerID': 863, 'userName': 'xscott', 'name': 'Samantha Wright'}, 'lastUpdatedTimestamp': 1035761482, 'language': 'ENGLISH'}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Represent class peace exactly health war morning.', 'messageTemplate': 'Realize price such shoulder pattern reach hear.', 'field': 'Level trade west couple loss mission.', 'parameter': {}, 'timestamp': 942541256}], 'currentPage': 998, 'size': 322} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "offset": offset, "limit": limit, "keywordMatch": keywordMatch, "parentID": parentID, "service": service, "keywords": keywords, "keywordField": keywordField, "sortBy": sortBy } response = get(url, json=body if body else None, verify=verify, headers=headers ) 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
[docs]@register_command(extending=("customers","v1","customer")) def add_customer( name: str = None, shortName: str = None, properties: dict = None, logoURL: str = None, accountManagerID: int = None, features: list = None, language: str = "ENGLISH", timeZone: str = "Europe/Oslo", type: str = "CUSTOMER", parentID: int = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Create a new customer (PUBLIC) :param str name: Name to set for new customer. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str shortName: shortName to set for new customer (must be unique). => [a-zA-Z0-9_\-\.]* :param dict properties: Properties to set for customer. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str logoURL: Customer logo data url. On format data:image/jpeg;base64,BASE64STRING. => Sanitize by regex data:.* :param int accountManagerID: ID of account manager to assign to customer. If not set, no account manager is set. :param list features: Features to enable on customer. :param str language: Language to set for customer. (default ENGLISH) :param str timeZone: Name of timezone to set for customer. (default Europe/Oslo) :param str type: Object type. If set to GROUP, this customer can have subcustomers. (default CUSTOMER) :param int parentID: ID of parent customer group to add this customer to. (default 0) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 258, 'limit': 550, 'responseCode': 200, 'count': 648, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Authority onto Mrs budget young lose inside.', 'messageTemplate': 'Admit ball I the discover sell what.', 'field': 'Guy born evening best something born onto.', 'parameter': {}, 'timestamp': 957568341}], 'currentPage': 292, 'size': 143} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "language": language, "timeZone": timeZone, "type": type, "parentID": parentID, "name": name, "shortName": shortName, "properties": properties, "logoURL": logoURL, "accountManagerID": accountManagerID, "features": features } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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
[docs]@register_command(extending=("customers","v1","customer")) def search_customers( limit: int = None, offset: int = None, subCriteria: list = None, customerID: list = None, parentID: list = None, keywords: list = None, keywordMatchStrategy: str = None, keywordFieldStrategy: list = None, service: list = None, domain: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, includeDeleted: bool = None, exclude: bool = None, required: bool = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns customers defined by CustomerSearchCriteria (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 list subCriteria: :param list customerID: Restrict search to data belonging to specified customers. :param list parentID: Search for customers by parent customer ID. :param list keywords: Search for customers by keywords. :param str keywordMatchStrategy: Defines the MatchStrategy for keywords (default match all keywords). :param list keywordFieldStrategy: Defines which fields will be searched by keywords (default all supported fields). :param list service: Search for customers having any of these services (service shortname). :param list domain: Search for customers in one of these domains (by domain id or name). :param list sortBy: List of properties to sort by (prefix with "-" to sort descending). :param list includeFlags: Only include objects which have includeFlags set. :param list excludeFlags: Exclude objects which have excludeFlags set. :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). :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 724, 'limit': 51, 'responseCode': 200, 'count': 833, 'data': [{'id': 438, 'flags': ['DISABLED'], 'name': 'Shelly Snyder', 'shortName': 'History benefit edge situation some southern song.', 'properties': {'additionalProperties': 'Check reach or hotel language.'}, 'services': [{'id': 370, 'name': 'Tina Crawford', 'description': 'Nearly during least however green suggest.'}], 'createdByUser': {'id': 423, 'customerID': 976, 'userName': 'paynechristine', 'name': 'Laurie Stewart'}, 'createdTimestamp': 1435542313, 'lastUpdatedByUser': {'id': 398, 'customerID': 709, 'userName': 'john72', 'name': 'Jamie Porter'}, 'accountManager': {'id': 488, 'customerID': 925, 'userName': 'kimmonique', 'name': 'Andrew Hood'}, 'lastUpdatedTimestamp': 297525859, 'language': 'ENGLISH'}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'School decide almost fire important in appear.', 'messageTemplate': 'Lose employee entire sit her beat entire.', 'field': 'Value behind difference point skin official impact.', 'parameter': {}, 'timestamp': 1091373458}], 'currentPage': 586, 'size': 186} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/search".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "limit": limit, "offset": offset, "includeDeleted": includeDeleted, "subCriteria": subCriteria, "exclude": exclude, "required": required, "customerID": customerID, "parentID": parentID, "keywords": keywords, "keywordMatchStrategy": keywordMatchStrategy, "keywordFieldStrategy": keywordFieldStrategy, "service": service, "domain": domain, "sortBy": sortBy, "includeFlags": includeFlags, "excludeFlags": excludeFlags } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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
[docs]@register_command(extending=("customers","v1","customer")) def add_customer_service( customerID: int, service: str = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Add a service to a customer. (PUBLIC) :param int customerID: Customer ID :param str service: Name of service to enable on customer :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 232, 'limit': 702, 'responseCode': 200, 'count': 316, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Like soon ok piece leave.', 'messageTemplate': 'Clear step too mention expect give.', 'field': 'New raise sound.', 'parameter': {}, 'timestamp': 385889385}], 'currentPage': 565, 'size': 324} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{customerID}/service".format(customerID=customerID) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "service": service } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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
[docs]@register_command(extending=("customers","v1","customer")) def remove_customer_service( customerID: int, service: str, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Remove a service from a customer. (PUBLIC) :param int customerID: Customer ID :param str service: Name of service to remove :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 945, 'limit': 727, 'responseCode': 200, 'count': 106, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Real once buy direction recently.', 'messageTemplate': 'Item though state whose yourself tough increase.', 'field': 'Prove simple west money report style until history.', 'parameter': {}, 'timestamp': 671482611}], 'currentPage': 849, 'size': 414} """ from requests import delete from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{customerID}/service/{service}".format(customerID=customerID, service=service) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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
[docs]@register_command(extending=("customers","v1","customer")) def get_customer_by_id( id: int, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns a Customer identified by its ID. (PUBLIC) :param int id: Customer ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 857, 'limit': 975, 'responseCode': 200, 'count': 218, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'List try spring shoulder we section artist.', 'messageTemplate': 'Computer poor work quickly yes including role news.', 'field': 'Surface whatever tough discussion.', 'parameter': {}, 'timestamp': 1447859866}], 'currentPage': 616, 'size': 524} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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
[docs]@register_command(extending=("customers","v1","customer")) def update_customer( id: int, name: str = None, shortName: str = None, language: str = None, addProperties: dict = None, deleteProperties: list = None, logoURL: str = None, timeZone: str = None, accountManagerID: int = None, addFeatures: list = None, deleteFeatures: list = None, type: str = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Update a customer object. (PUBLIC) :param int id: Customer ID :param str name: If set, change customer name to this value. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param str shortName: If set, change customer shortname to this value (must be unique). => [a-zA-Z0-9_\-\.]* :param str language: If set, change customer language. :param dict addProperties: If set, add these properties. If the keys exist, they will be overwritten. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]* :param list deleteProperties: If set, remove properties with these keys. Missing keys are ignored. :param str logoURL: If set, change customer logo. On format data:image/jpeg;base64,BASE64STRING. => Sanitize by regex data:.* :param str timeZone: If set, change customer timezone to timezone with this name. :param int accountManagerID: If set, change customer account manmager to specified user. :param list addFeatures: If set, add these features to customer. :param list deleteFeatures: If set, remove these features from customer. :param str type: Customer type. If set to GROUP, this customer can have subcustomers. :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 577, 'limit': 490, 'responseCode': 200, 'count': 371, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Seat unit Mrs officer.', 'messageTemplate': 'Mother market fund mention media onto last.', 'field': 'Lot kid occur because.', 'parameter': {}, 'timestamp': 1141699150}], 'currentPage': 662, 'size': 834} """ from requests import put from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "name": name, "shortName": shortName, "language": language, "addProperties": addProperties, "deleteProperties": deleteProperties, "logoURL": logoURL, "timeZone": timeZone, "accountManagerID": accountManagerID, "addFeatures": addFeatures, "deleteFeatures": deleteFeatures, "type": type } response = put(url, json=body if body else None, verify=verify, headers=headers ) 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
[docs]@register_command(extending=("customers","v1","customer")) def disable_customer( id: int, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Disable customer. (PUBLIC) :param int id: Customer ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 349, 'limit': 408, 'responseCode': 200, 'count': 724, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Child accept wear term improve author have.', 'messageTemplate': 'Seek stock can consider old everybody second.', 'field': 'Night economic area can reason.', 'parameter': {}, 'timestamp': 301452404}], 'currentPage': 412, 'size': 565} """ from requests import delete from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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
[docs]@register_command(extending=("customers","v1","customer")) def get_customer_logo_by_id( id: int, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns a Customer logo by customer shortname. (PUBLIC) :param int id: Customer ID :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{id}/logo".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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
[docs]@register_command(extending=("customers","v1","customer")) def get_customer_by_shortname( shortName: str, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns a Customer identified by its shortname. (PUBLIC) :param str shortName: Customer shortname :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 23, 'limit': 523, 'responseCode': 200, 'count': 974, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Hope amount more material practice.', 'messageTemplate': 'Rest professional pretty at decision within.', 'field': 'Say fact money media change individual.', 'parameter': {}, 'timestamp': 120084980}], 'currentPage': 311, 'size': 11} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{shortName}".format(shortName=shortName) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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
[docs]@register_command(extending=("customers","v1","customer")) def get_customer_logo_by_shortname( shortName: str, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Returns a Customer logo by customer shortname. (PUBLIC) :param str shortName: Customer shortname :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/customers/v1/customer/{shortName}/logo".format(shortName=shortName) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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