def getRequest(self, request_id): sd_ip = "10.71.67.39" try: print(sd_ip) token = Login.login(sd_ip) logging.debug(token) if token != None: header = {"Authorization": "Berear " + token} url = "https://" + sd_ip + "/LiveTime/services/v1/customer/requests/{}".format( request_id) rest_data, rest_status = RestFactory().make_get_request( url, header) logging.debug(rest_status) if rest_status == 200: jsonResponse = json.loads(rest_data.decode('utf-8')) else: jsonResponse = "No Request" logging.debug(jsonResponse) else: jsonResponse = None return jsonResponse except Exception as ex: print(traceback.format_exc()) return None
def create_request(self, description): try: sd_ip = "10.71.64.192" req_id = None token = Login.login(sd_ip) logging.debug(token) if token != None: header = { "Authorization": "Berear " + token, "Content-Type": "application/json" } post_body_data = '{"requestDescription":' + '"' + description + '"' + ', "subject":"Item category: Service and Item Type: Service Desk"}' url = "https://" + sd_ip + "/LiveTime/services/v1/customer/requests" rest_data, rest_status = RestFactory().make_post_request( url, post_body_data, header) logging.debug(rest_status) if rest_status == 200: req_id = json.loads(rest_data.decode('utf-8')) logging.debug(req_id) return req_id except Exception as ex: print(traceback.format_exc()) return None