예제 #1
0
    def deleteFeed(self, args, props, res):
        trigger = json.loads(res.read())
        hasFeed = [a['value'] for a in  trigger['annotations'] if a['key'] == 'feed']
        feedName = hasFeed[0] if hasFeed else None

        if feedName:
            ns = props['namespace']
            triggerName = getQName(args.name, ns)

            parameters = []
            parameters.append([ 'lifecycleEvent', 'DELETE' ])
            parameters.append([ 'triggerName', triggerName ])
            parameters.append([ 'authKey', args.auth ])

            feedArgs = {
                'verbose': args.verbose,
                'name' : feedName,
                'param': parameters,
                'blocking': True,
                'auth': args.auth
            }

            feedResponse = Action().doInvoke(dict2obj(feedArgs), props)
            if feedResponse.status == httplib.OK:
                return self.deleteResponse(args, res)
            else:
                print 'error: failed to delete %s feed %s but did delete the trigger' % (self.name, args.name)
                return responseError(feedResponse, None)
예제 #2
0
    def createFeed(self, args, props, putResponse):
        ns = props['namespace']
        triggerName = getQName(args.name, ns)

        parameters = args.param
        if parameters is None:
            parameters = []
        parameters.append([ 'lifecycleEvent', 'CREATE' ])
        parameters.append([ 'triggerName', triggerName ])
        parameters.append([ 'authKey', args.auth ])

        feedArgs = {
            'verbose': args.verbose,
            'name' : args.feed,
            'param': parameters,
            'blocking': True,
            'auth': args.auth
        }

        feedResponse = Action().doInvoke(dict2obj(feedArgs), props)
        if feedResponse.status == httplib.OK:
            print 'ok: created %s feed %s' % (self.name, args.name)
        else:
            print 'error: failed to create %s feed %s' % (self.name, args.name)
            # clean up by deleting trigger
            self.httpDelete(args, props)
            return responseError(feedResponse, None)
예제 #3
0
 def printCollection(self, result, collection):
     if collection in result:
         print bold(collection)
         for e in result[collection]:
             if collection == 'actions':
                 print Action().formatListEntity(e)
             elif collection == 'triggers':
                 print Trigger().formatListEntity(e)
             elif collection == 'rules':
                 print Rule().formatListEntity(e)
             elif collection == 'packages':
                 print Package().formatListEntity(e)