예제 #1
0
    def testEventDefaults(self):
        expectedSource = {"ref": platform.node(), "type": "host"}
        e = Event.getDefaultEvent()

        self.assertIsNone(e.organizationID)
        self.assertIsNotNone(e.title)
        self.assertEqual(e.source, expectedSource)
예제 #2
0
 def testEventDefaults(self):
     expectedSource = { "ref": platform.node(),"type": "host"}
     e = Event.getDefaultEvent()
     
     self.assertIsNone(e.organizationID)
     self.assertIsNotNone(e.title)
     self.assertEqual(e.source,expectedSource)
예제 #3
0
def createEvent(apiHost,
                apiKey,
                fingerprintFields,
                title,
                organizationID,
                source={
                    'ref': platform.node(),
                    'type': 'host'
                },
                severity=Event.INFO,
                sender={
                    'ref': platform.node(),
                    'type': 'host'
                },
                properties=None,
                status=Event.OK,
                tags=None,
                message=None,
                createdAt=None,
                receivedAt=None,
                eventId=None):
    c = EventConnection(apiKey=apiKey,
                        organizationID=organizationID,
                        apiHost=apiHost)

    e = Event(source, fingerprintFields, title, organizationID, severity,
              sender, properties, status, tags, message, createdAt, receivedAt,
              eventId)

    print(c.createEvent(e))
예제 #4
0
    def testCreateEvent(self):
        # Create our Boundary Event Connection
        connection = EventConnection(self.apiKey, self.organizationID)
        event = Event.getDefaultEvent()

        #Send an event to the Boundary Server using the Boundary REST API
        eventID = connection.createEvent(event)
        self.assertIsNotNone(eventID, 'Check for returned event ID')
예제 #5
0
 def testCreateEvent(self):
     # Create our Boundary Event Connection
     connection = EventConnection(self.apiKey,
                                  self.organizationID)
     event = Event.getDefaultEvent()
       
       
     #Send an event to the Boundary Server using the Boundary REST API
     eventID = connection.createEvent(event)
     self.assertIsNotNone(eventID,'Check for returned event ID')
예제 #6
0
    def getEvent(self, eventId):
        """
        """
        # TODO: checks to ensure event ID is a number
        uri = self.__uri + '/' + str(eventId)

        r = requests.get(uri,
                         headers=self.__getEventHeaders,
                         auth=self.__authorization)
        print('HTTP Status Code: ' + str(r.status_code))
        print(r.text)
        e = json.loads(r.text)
        return Event.toEvent(e)
예제 #7
0
 def testDefaults(self):
     e = Event(source='MySource',
               fingerprintFields='@title',
               title='MyTitle')
     self.assertEqual(e.severity, e.INFO, 'Check default value of severity')
     self.assertEqual(e.organizationID, None,
                      'Check default value of organizationID')
     self.assertEqual(e.sender, {
         "ref": platform.node(),
         "type": "host"
     }, 'Check default value of sender')
     self.assertEqual(e.properties, None,
                      'Check default value of properties')
예제 #8
0
    def getEvent(self,eventId):
        """
        """
        # TODO: checks to ensure event ID is a number
        uri = self.__uri + '/' + str(eventId)
        
        r = requests.get(uri,headers=self.__getEventHeaders, auth=self.__authorization)
        print('HTTP Status Code: ' + str(r.status_code))
        print(r.text)
        e = json.loads(r.text)
        return Event.toEvent(e)


    
        
        
예제 #9
0
def main():
    k = 'ARI0PzUzWYUo7GG1OxiHmABTpr9'
    o = '3ehRi7uZeeaTN12dErF5XOnRXjC'
    connection = EventConnection(apiKey=k,organizationID=o)
    event = Event.getDefaultEvent()
    
    event.message = 'Hello World'
    event.title = 'Boundary Object Oriented Event API'
    
    eventId = connection.createEvent(event)
    
    print('event id: ' + str(eventId))
    
    newEvent = connection.getEvent(eventId)
    
    print('event: ' + newEvent)
예제 #10
0
def main():
    k = 'ARI0PzUzWYUo7GG1OxiHmABTpr9'
    o = '3ehRi7uZeeaTN12dErF5XOnRXjC'
    connection = EventConnection(apiKey=k, organizationID=o)
    event = Event.getDefaultEvent()

    event.message = 'Hello World'
    event.title = 'Boundary Object Oriented Event API'

    eventId = connection.createEvent(event)

    print('event id: ' + str(eventId))

    newEvent = connection.getEvent(eventId)

    print('event: ' + newEvent)
예제 #11
0
 def setUp(self):
     self.event = Event.getDefaultEvent()
     pass
예제 #12
0
 def testEventDict(self):
     d = {'title': 'Hello'}
     event = Event.toEvent(d)
     print(event)
예제 #13
0
 def setUp(self):
     self.event = Event.getDefaultEvent()
     pass
예제 #14
0
 def testEventDict(self):
     d = {'title': 'Hello'}
     event = Event.toEvent(d)
     print(event)