Exemple #1
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('list', help='retrieve activations')
        subcmd.add_argument('name', nargs='?', help='the namespace or action to list')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-s', '--skip', help='skip this many entities from the head of the collection', type=int, default=0)
        subcmd.add_argument('-l', '--limit', help='only return this many entities from the collection', type=int, default=30)
        subcmd.add_argument('-f', '--full', help='return full documents for each activation', action='store_true')
        subcmd.add_argument('--upto', help='return activations with timestamps earlier than UPTO; measured in milliseconds since Thu, 01 Jan 1970 00:00:00',  type=long, default=0)
        subcmd.add_argument('--since', help='return activations with timestamps later than SINCE; measured in milliseconds since Thu, 01 Jan 1970 00:00:00', type=long, default=0)

        subcmd = parser.add_parser('get', help='get %s' % self.name)
        subcmd.add_argument('name', help='the name of the %s' % self.name)
        subcmd.add_argument('project', nargs='?', help='project only this property')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-s', '--summary', help='summarize entity details', action='store_true')

        subcmd = parser.add_parser('logs', help='get the logs of an activation')
        subcmd.add_argument('id', help='the activation id')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-s', '--strip', help='strip timestamp and stream information', action='store_true')

        subcmd= parser.add_parser('result', help='get the result of an activation')
        subcmd.add_argument('id', help='the invocation id')
        addAuthenticatedCommand(subcmd, props)

        # poll
        subcmd= parser.add_parser('poll', help='poll continuously for log messages from currently running actions')
        subcmd.add_argument('name', nargs='?', help='the namespace to poll')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-e', '--exit', help='exit after this many seconds', type=int, default=-1)
        subcmd.add_argument('-ss', '--since-seconds', help='start polling for activations this many seconds ago', type=long, default=0, dest='since_secs')
        subcmd.add_argument('-sm', '--since-minutes', help='start polling for activations this many minutes ago', type=long, default=0, dest='since_mins')
        subcmd.add_argument('-sh' ,'--since-hours', help='start polling for activations this many hours ago', type=long, default=0, dest='since_hrs')
        subcmd.add_argument('-sd' ,'--since-days', help='start polling for activations this many days ago', type=long, default=0, dest='since_days')
    def getCommands(self, parser, props):
        commands = parser.add_parser('namespace', help='work with namespaces')

        subcmds = commands.add_subparsers(title='available commands', dest='subcmd')

        subcmd = subcmds.add_parser('list', help='list available namespaces')
        addAuthenticatedCommand(subcmd, props)

        subcmd = subcmds.add_parser('get', help='get entities in namespace')
        subcmd.add_argument('name', nargs='?', help='the namespace to list')
        addAuthenticatedCommand(subcmd, props)
    def getCommands(self, parser, props):
        commands = parser.add_parser('namespace', help='work with namespaces')

        subcmds = commands.add_subparsers(title='available commands',
                                          dest='subcmd')

        subcmd = subcmds.add_parser('list', help='list available namespaces')
        addAuthenticatedCommand(subcmd, props)

        subcmd = subcmds.add_parser('get', help='get entities in namespace')
        subcmd.add_argument('name', nargs='?', help='the namespace to list')
        addAuthenticatedCommand(subcmd, props)
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create a new package')
        subcmd.add_argument('name', help='the name of the package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')

        subcmd = parser.add_parser('update', help='create a new package')
        subcmd.add_argument('name', help='the name of the package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')

        subcmd = parser.add_parser('bind', help='bind parameters to the package')
        subcmd.add_argument('package', help='the name of the package')
        subcmd.add_argument('name', help='the name of the bound package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')

        subcmd = parser.add_parser('refresh', help='refresh package bindings')
        subcmd.add_argument('name', nargs='?', help='the namespace to refresh')
        addAuthenticatedCommand(subcmd, props)

        self.addDefaultCommands(parser, props)
Exemple #5
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create a new package')
        subcmd.add_argument('name', help='the name of the package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')

        subcmd = parser.add_parser('update', help='create a new package')
        subcmd.add_argument('name', help='the name of the package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        
        subcmd = parser.add_parser('bind', help='bind parameters to the package')
        subcmd.add_argument('package', help='the name of the package')
        subcmd.add_argument('name', help='the name of the bound package')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        
        subcmd = parser.add_parser('refresh', help='refresh package bindings')
        subcmd.add_argument('name', nargs='?', help='the namespace to refresh')
        addAuthenticatedCommand(subcmd, props)
        
        self.addDefaultCommands(parser, props)
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new trigger')
        subcmd.add_argument('name', help='the name of the trigger')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')
        subcmd.add_argument('-a',
                            '--annotation',
                            help='annotations',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-p',
                            '--param',
                            help='default parameters',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-f', '--feed', help='trigger feed')

        subcmd = parser.add_parser('update', help='update an existing trigger')
        subcmd.add_argument('name', help='the name of the trigger')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')
        subcmd.add_argument('-a',
                            '--annotation',
                            help='annotations',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-p',
                            '--param',
                            help='default parameters',
                            nargs=2,
                            action='append')

        subcmd = parser.add_parser('fire', help='fire trigger event')
        subcmd.add_argument('name', help='the name of the trigger')
        subcmd.add_argument('payload',
                            help='the payload to attach to the trigger',
                            nargs='?')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-p',
                            '--param',
                            help='parameters',
                            nargs=2,
                            action='append')

        self.addDefaultCommands(parser, props)
Exemple #7
0
    def addDefaultCommands(self, subcmds, props, which = ['get', 'delete', 'list']):
        if ('get' in which):
            subcmd = subcmds.add_parser('get', help='get %s' % self.name)
            subcmd.add_argument('name', help='the name of the %s' % self.name)
            subcmd.add_argument('project', nargs='?', help='project only this property')
            addAuthenticatedCommand(subcmd, props)
            subcmd.add_argument('-s', '--summary', help='summarize entity details', action='store_true')

        if ('delete' in which):
            subcmd = subcmds.add_parser('delete', help='delete %s' % self.name)
            subcmd.add_argument('name', help='the name of the %s' % self.name)
            addAuthenticatedCommand(subcmd, props)

        if ('list' in which):
            subcmd = subcmds.add_parser('list', help='list all %s' % self.collection)
            subcmd.add_argument('name', nargs='?', help='the namespace to list')
            addAuthenticatedCommand(subcmd, props)
            subcmd.add_argument('-s', '--skip', help='skip this many entities from the head of the collection', type=int, default=0)
            subcmd.add_argument('-l', '--limit', help='only return this many entities from the collection', type=int, default=30)
Exemple #8
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new action')
        subcmd.add_argument('--kind', help='the kind of the action runtime (example: swift:3)', type=str)
        subcmd.add_argument('name', help='the name of the action')
        subcmd.add_argument('artifact', help='artifact (e.g., file name) containing action definition')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--docker', help='treat artifact as docker image path on dockerhub', action='store_true')
        subcmd.add_argument('--copy', help='treat artifact as the name of an existing action', action='store_true')
        subcmd.add_argument('--sequence', help='treat artifact as comma separated sequence of actions to invoke', action='store_true')
        subcmd.add_argument('--lib', help='add library to artifact (must be a gzipped tar file)', type=argparse.FileType('r'))
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('-t', '--timeout', help='the timeout limit in milliseconds when the action will be terminated', type=int)
        subcmd.add_argument('-m', '--memory', help='the memory limit in MB of the container that runs the action', type=int)
        subcmd.add_argument('-l', '--logsize', help='the logsize limit in MB of the container that runs the action', type=int)

        subcmd = parser.add_parser('update', help='update an existing action')
        subcmd.add_argument('--kind', help='the kind of the action runtime (example: swift:3)', type=str)
        subcmd.add_argument('name', help='the name of the action')
        subcmd.add_argument('artifact', nargs='?', default=None, help='artifact (e.g., file name) containing action definition')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--docker', help='treat artifact as docker image path on dockerhub', action='store_true')
        subcmd.add_argument('--copy', help='treat artifact as the name of an existing action', action='store_true')
        subcmd.add_argument('--sequence', help='treat artifact as comma separated sequence of actions to invoke', action='store_true')
        subcmd.add_argument('--lib', help='add library to artifact (must be a gzipped tar file)', type=argparse.FileType('r'))
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('-t', '--timeout', help='the timeout limit in milliseconds when the action will be terminated', type=int)
        subcmd.add_argument('-m', '--memory', help='the memory limit in MB of the container that runs the action', type=int)
        subcmd.add_argument('-l', '--logsize', help='the logsize limit in MB of the container that runs the action', type=int)

        subcmd = parser.add_parser('invoke', help='invoke action')
        subcmd.add_argument('name', help='the name of the action to invoke')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-p', '--param', help='parameters', nargs=2, action='append')
        subcmd.add_argument('-b', '--blocking', action='store_true', help='blocking invoke')
        subcmd.add_argument('-r', '--result', help='show only activation result if a blocking activation (unless there is a failure)', action='store_true')

        self.addDefaultCommands(parser, props)
Exemple #9
0
    def addDefaultCommands(self,
                           subcmds,
                           props,
                           which=['get', 'delete', 'list']):
        if ('get' in which):
            subcmd = subcmds.add_parser('get', help='get %s' % self.name)
            subcmd.add_argument('name', help='the name of the %s' % self.name)
            subcmd.add_argument('project',
                                nargs='?',
                                help='project only this property')
            addAuthenticatedCommand(subcmd, props)
            subcmd.add_argument('-s',
                                '--summary',
                                help='summarize entity details',
                                action='store_true')

        if ('delete' in which):
            subcmd = subcmds.add_parser('delete', help='delete %s' % self.name)
            subcmd.add_argument('name', help='the name of the %s' % self.name)
            addAuthenticatedCommand(subcmd, props)

        if ('list' in which):
            subcmd = subcmds.add_parser('list',
                                        help='list all %s' % self.collection)
            subcmd.add_argument('name',
                                nargs='?',
                                help='the namespace to list')
            addAuthenticatedCommand(subcmd, props)
            subcmd.add_argument(
                '-s',
                '--skip',
                help='skip this many entities from the head of the collection',
                type=int,
                default=0)
            subcmd.add_argument(
                '-l',
                '--limit',
                help='only return this many entities from the collection',
                type=int,
                default=30)
Exemple #10
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new trigger')
        subcmd.add_argument('name', help='the name of the trigger')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')
        subcmd.add_argument('-f', '--feed', help='trigger feed')

        subcmd = parser.add_parser('update', help='update an existing trigger')
        subcmd.add_argument('name', help='the name of the trigger')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        subcmd.add_argument('-a', '--annotation', help='annotations', nargs=2, action='append')
        subcmd.add_argument('-p', '--param', help='default parameters', nargs=2, action='append')

        subcmd = parser.add_parser('fire', help='fire trigger event')
        subcmd.add_argument('name', help='the name of the trigger')
        subcmd.add_argument('payload', help='the payload to attach to the trigger', nargs ='?')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-p', '--param', help='parameters', nargs=2, action='append')

        self.addDefaultCommands(parser, props)
Exemple #11
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new rule')
        subcmd.add_argument('name', help='the name of the rule')
        subcmd.add_argument('trigger', help='the trigger')
        subcmd.add_argument('action', help='the action')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')
        subcmd.add_argument('--enable',
                            help='enable rule after creating it',
                            action='store_true',
                            default=False)

        subcmd = parser.add_parser('delete', help='delete %s' % self.name)
        subcmd.add_argument('name', help='the name of the %s' % self.name)
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument(
            '--disable',
            help='automatically disable rule before deleting it',
            action='store_true',
            default=False)

        subcmd = parser.add_parser('update', help='update an existing rule')
        subcmd.add_argument('name', help='the name of the rule')
        subcmd.add_argument('trigger', help='the trigger')
        subcmd.add_argument('action', help='the action')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')

        subcmd = parser.add_parser('enable', help='enable rule')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        subcmd = parser.add_parser('disable', help='disable rule')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        subcmd = parser.add_parser('status', help='get rule status')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        self.addDefaultCommands(parser, props, ['get', 'list'])
Exemple #12
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new action')
        subcmd.add_argument(
            '--kind',
            help='the kind of the action runtime (example: swift:3)',
            type=str)
        subcmd.add_argument('name', help='the name of the action')
        subcmd.add_argument(
            'artifact',
            help='artifact (e.g., file name) containing action definition')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument(
            '--docker',
            help='treat artifact as docker image path on dockerhub',
            action='store_true')
        subcmd.add_argument(
            '--copy',
            help='treat artifact as the name of an existing action',
            action='store_true')
        subcmd.add_argument(
            '--sequence',
            help=
            'treat artifact as comma separated sequence of actions to invoke',
            action='store_true')
        subcmd.add_argument(
            '--lib',
            help='add library to artifact (must be a gzipped tar file)',
            type=argparse.FileType('r'))
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')
        subcmd.add_argument('-a',
                            '--annotation',
                            help='annotations',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-p',
                            '--param',
                            help='default parameters',
                            nargs=2,
                            action='append')
        subcmd.add_argument(
            '-t',
            '--timeout',
            help=
            'the timeout limit in milliseconds when the action will be terminated',
            type=int)
        subcmd.add_argument(
            '-m',
            '--memory',
            help='the memory limit in MB of the container that runs the action',
            type=int)

        subcmd = parser.add_parser('update', help='update an existing action')
        subcmd.add_argument(
            '--kind',
            help='the kind of the action runtime (example: swift:3)',
            type=str)
        subcmd.add_argument('name', help='the name of the action')
        subcmd.add_argument(
            'artifact',
            nargs='?',
            default=None,
            help='artifact (e.g., file name) containing action definition')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument(
            '--docker',
            help='treat artifact as docker image path on dockerhub',
            action='store_true')
        subcmd.add_argument(
            '--copy',
            help='treat artifact as the name of an existing action',
            action='store_true')
        subcmd.add_argument(
            '--sequence',
            help=
            'treat artifact as comma separated sequence of actions to invoke',
            action='store_true')
        subcmd.add_argument(
            '--lib',
            help='add library to artifact (must be a gzipped tar file)',
            type=argparse.FileType('r'))
        subcmd.add_argument('--shared',
                            nargs='?',
                            const='yes',
                            choices=['yes', 'no'],
                            help='shared action (default: private)')
        subcmd.add_argument('-a',
                            '--annotation',
                            help='annotations',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-p',
                            '--param',
                            help='default parameters',
                            nargs=2,
                            action='append')
        subcmd.add_argument(
            '-t',
            '--timeout',
            help=
            'the timeout limit in milliseconds when the action will be terminated',
            type=int)
        subcmd.add_argument(
            '-m',
            '--memory',
            help='the memory limit in MB of the container that runs the action',
            type=int)

        subcmd = parser.add_parser('invoke', help='invoke action')
        subcmd.add_argument('name', help='the name of the action to invoke')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('-p',
                            '--param',
                            help='parameters',
                            nargs=2,
                            action='append')
        subcmd.add_argument('-b',
                            '--blocking',
                            action='store_true',
                            help='blocking invoke')
        subcmd.add_argument(
            '-r',
            '--result',
            help=
            'show only activation result if a blocking activation (unless there is a failure)',
            action='store_true')

        self.addDefaultCommands(parser, props)
Exemple #13
0
    def getItemSpecificCommands(self, parser, props):
        subcmd = parser.add_parser('create', help='create new rule')
        subcmd.add_argument('name', help='the name of the rule')
        subcmd.add_argument('trigger', help='the trigger')
        subcmd.add_argument('action', help='the action')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')
        subcmd.add_argument('--enable', help='enable rule after creating it', action='store_true', default=False)

        subcmd = parser.add_parser('delete', help='delete %s' % self.name)
        subcmd.add_argument('name', help='the name of the %s' % self.name)
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--disable', help='automatically disable rule before deleting it', action='store_true', default=False)

        subcmd = parser.add_parser('update', help='update an existing rule')
        subcmd.add_argument('name', help='the name of the rule')
        subcmd.add_argument('trigger', help='the trigger')
        subcmd.add_argument('action', help='the action')
        addAuthenticatedCommand(subcmd, props)
        subcmd.add_argument('--shared', nargs='?', const='yes', choices=['yes', 'no'], help='shared action (default: private)')

        subcmd = parser.add_parser('enable', help='enable rule')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        subcmd = parser.add_parser('disable', help='disable rule')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        subcmd = parser.add_parser('status', help='get rule status')
        subcmd.add_argument('name', help='the name of the rule')
        addAuthenticatedCommand(subcmd, props)

        self.addDefaultCommands(parser, props, ['get', 'list'])