예제 #1
0
 def create(self, payload, account_name, **kwargs):
     kwargs.setdefault(
         'headers',
         {})['X-Forwarded-Host'] = account_name + '.serverdensity.io'
     payload = json.dumps(payload)
     kwargs.setdefault('data', {})['payload'] = payload
     kwargs['data']['hash'] = md5(payload.encode('utf-8')).hexdigest()
     return Response(self.api.post(url=self.PATHS['create'], **kwargs))
예제 #2
0
    def triggered(self, _id=None, subject_type=None, closed=None, **kwargs):
        kwargs.setdefault('params', {})
        kwargs['params'].setdefault('filter', {})
        if _id and subject_type:
            filter = {
                'config.subjectType': subject_type,
                'config.subjectId': _id
            }
            kwargs['params']['filter'] = filter

        if closed:
            kwargs['params'].setdefault('filter', {})['fixed'] = closed
        kwargs['params']['filter'] = json.dumps(kwargs['params']['filter'],
                                                sort_keys=True)
        result = self.api.get(url=self.PATHS['triggered'], **kwargs)
        return [Response(item) for item in result]
예제 #3
0
 def service_metrics(self, **kwargs):
     return Response(
         self.api.get(url=self.PATHS['service_metrics'], **kwargs))
예제 #4
0
 def get(self, _id, start, end, filtering, **kwargs):
     kwargs.setdefault('params', {})['start'] = start.isoformat()
     kwargs['params']['end'] = end.isoformat()
     kwargs['params']['filter'] = json.dumps(filtering)
     result = self.api.get(url=self.PATHS['get'].format(_id), **kwargs)
     return [Response(item) for item in result]
예제 #5
0
 def available(self, _id, start, end, **kwargs):
     kwargs.setdefault('params', {})['start'] = start.isoformat()
     kwargs['params']['end'] = end.isoformat()
     result = self.api.get(url=self.PATHS['available'].format(_id),
                           **kwargs)
     return [Response(item) for item in result]
 def test_response_contains_a_list_of_response_objects(self):
     data = {'data': [{'1': 'a'}, {'2': 'b'}]}
     response = Response(data)
     self.assertEqual(isinstance(response.data[0], Response), True)
 def test_a_deep_property_works(self):
     response = Response(self.data)
     self.assertEqual(response.data.some_more, 'result')
 def test_a_single_property_works(self):
     response = Response(self.data)
     self.assertEqual(response.property, 'result')