예제 #1
0
 def fetch_trace(self, uuid):
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(
             Trace(json.loads(response.content.decode('utf-8'))),
             response.status_code, response.text)
     else:
         print("get trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
예제 #2
0
 def delete_experiment(self, uuid):
     api_url = '{0}experiments/{1}'.format(self.base_url, uuid)
     response = requests.delete(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(
             Trace(json.loads(response.content.decode('utf-8'))),
             response.status_code, response.text)
     else:
         print("delete experiment failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
예제 #3
0
 def fetch_trace(self, uuid):
     '''
     Fetch a specific trace information
     :param uuid: Trace UUID to fetch
     :return: :class:`TspClientResponse <Trace>` object
     :rtype: TspClientResponse
     '''
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     response = requests.get(api_url, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:
         print("get trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
예제 #4
0
    def open_trace(self, name, path):
        api_url = '{0}traces'.format(self.base_url)

        my_parameters = {'name': name, 'uri': path}
        parameters = {'parameters': my_parameters}

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(
                Trace(json.loads(response.content.decode('utf-8'))),
                response.status_code, response.text)
        else:
            print("post trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
예제 #5
0
 def delete_trace(self, uuid, delete_trace, remove_cache=False):
     api_url = '{0}traces/{1}'.format(self.base_url, uuid)
     parameters = {};
     if delete_trace: 
         parameters.append('deleteTrace', "true")
     
     if remove_cache: {
         parameters.append('removeCache', "true")
     }
     response = requests.delete(api_url, json=parameters, headers=headers)
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     else:
         print ("delete trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
예제 #6
0
    def open_trace(self, name, path):
        '''
        Open a trace on the server
        parameters: Query object
        :return: :class:`TspClientResponse <Trace>` object
        :rtype: TspClientResponse
        '''
        api_url = '{0}traces'.format(self.base_url)

        my_parameters = {'name': name, 'uri': path}
        parameters = {'parameters': my_parameters}

        response = requests.post(api_url, json=parameters, headers=headers)

        if response.status_code == 200:
            return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("post trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)
예제 #7
0
 def open_trace(self, name, path):
     api_url = '{0}traces'.format(self.base_url)
     
     my_parameters = {'name': name, 'uri': path}
     parameters = {'parameters': my_parameters}
     
     response = requests.post(api_url, json=parameters, headers=headers)
     
     if response.status_code == 200:
         return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
     elif response.status_code == 409:
         fetch_response = self.fetch_traces()
         if fetch_response.status_code == 200:
             #TODO don't just blindly use the first one
             return TspClientResponse(fetch_response.model.traces[0], response.status_code, response.text)
         else:
             return TspClientResponse(None, fetch_response.status_code, fetch_response.status_text)
     else:
         print ("post trace failed: {0}".format(response.status_code))
         return TspClientResponse(None, response.status_code, response.text)
예제 #8
0
    def delete_trace(self, uuid, delete_trace, remove_cache=False):
        '''
        Delete a trace on the server
        :param uuid: Trace UUID to delete
        :param delete_trace: Also delete the trace from disk
        :param remove_cache: Remove all cache for this trace
        :return: :class:`TspClientResponse <Trace>` object
        :rtype: TspClientResponse
        '''
        api_url = '{0}traces/{1}'.format(self.base_url, uuid)
        parameters = {}
        if delete_trace:  # pragma: no cover
            parameters['deleteTrace'] = "true"

        if remove_cache:
            parameters['removeCache'] = "true"

        response = requests.delete(api_url, json=parameters, headers=headers)
        if response.status_code == 200:
            return TspClientResponse(Trace(json.loads(response.content.decode('utf-8'))), response.status_code, response.text)
        else:  # pragma: no cover
            print("delete trace failed: {0}".format(response.status_code))
            return TspClientResponse(None, response.status_code, response.text)