def create(self, args, props, update): exe = self.getExec(args, props) if args.sequence: if args.param is None: args.param = [] ns = props['namespace'] actions = self.csvToList(args.artifact) actions = [getQName(a, ns) for a in actions] args.param.append(['_actions', json.dumps(actions)]) validExe = exe is not None and 'kind' in exe if update or validExe: # if create action, then exe must be valid payload = {} if args.annotation: payload['annotations'] = getAnnotations(args) if args.param: payload['parameters'] = getParams(args) # API will accept limits == {} as limits not specified on an update if args.timeout or args.memory: payload['limits'] = self.getLimits(args) if validExe: payload['exec'] = exe if args.shared: self.addPublish(payload, args) return self.put(args, props, update, json.dumps(payload)) else: if not args.copy: print 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact else: print 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact return 2
def bind(self, args, props): namespace, pname = parseQName(args.name, props) url = '%(apibase)s/namespaces/%(namespace)s/packages/%(name)s' % { 'apibase': apiBase(props), 'namespace': urllib.quote(namespace), 'name': self.getSafeName(pname) } pkgNamespace, pkgName = parseQName(args.package, props) if pkgName is None or len(pkgName) <= 0: print 'package name malformed. name or /namespace/name allowed' sys.exit(1) binding = { 'namespace': pkgNamespace, 'name': pkgName } payload = { 'binding': binding, 'annotations': getAnnotations(args), 'parameters': getParams(args) } args.shared = False self.addPublish(payload, args) headers= { 'Content-Type': 'application/json' } res = request('PUT', url, json.dumps(payload), headers, auth=args.auth, verbose=args.verbose) if res.status == httplib.OK: print 'ok: created binding %(name)s ' % {'name': args.name } return 0 else: return responseError(res)
def bind(self, args, props): namespace, pname = parseQName(args.name, props) url = 'https://%(apibase)s/namespaces/%(namespace)s/packages/%(name)s' % { 'apibase': apiBase(props), 'namespace': urllib.quote(namespace), 'name': self.getSafeName(pname) } pkgNamespace, pkgName = parseQName(args.package, props) if pkgName is None or len(pkgName) <= 0: print 'package name malformed. name or /namespace/name allowed' sys.exit(1) binding = { 'namespace': pkgNamespace, 'name': pkgName } payload = { 'binding': binding, 'annotations': getAnnotations(args), 'parameters': getParams(args) } args.shared = False self.addPublish(payload, args) headers= { 'Content-Type': 'application/json' } res = request('PUT', url, json.dumps(payload), headers, auth=args.auth, verbose=args.verbose) if res.status == httplib.OK: print 'ok: created binding %(name)s ' % {'name': args.name } return 0 else: return responseError(res)
def create(self, args, props, update): exe = self.getExec(args, props) if args.sequence: if args.param is None: args.param = [] ns = props['namespace'] actions = self.csvToList(args.artifact) actions = [ getQName(a, ns) for a in actions ] args.param.append([ '_actions', json.dumps(actions)]) validExe = exe is not None and 'kind' in exe if update or validExe: # if create action, then exe must be valid payload = {} if args.annotation: payload['annotations'] = getAnnotations(args) if args.param: payload['parameters'] = getParams(args) # API will accept limits == {} as limits not specified on an update if args.timeout or args.memory: payload['limits'] = self.getLimits(args) if validExe: payload['exec'] = exe if args.shared: self.addPublish(payload, args) return self.put(args, props, update, json.dumps(payload)) else: if not args.copy: print 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact else: print 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact return 2
def create(self, args, props, update): exe = self.getExec(args, props) validExe = exe is not None and 'kind' in exe fileok = args.artifact is None or os.path.isfile(args.artifact) if (update and fileok ) or validExe: # if create action, then exe must be valid payload = {} if args.annotation: payload['annotations'] = getAnnotations(args) if args.param: payload['parameters'] = getParams(args) # API will accept limits == {} as limits not specified on an update if not args.timeout is None or not args.memory is None or not args.logsize is None: payload['limits'] = self.getLimits(args) if validExe: payload['exec'] = exe if args.shared: self.addPublish(payload, args) return self.put(args, props, update, json.dumps(payload)) else: if not args.copy: print >> sys.stderr, 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact else: print >> sys.stderr, 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact return 2
def create(self, args, props, update): payload = {} if args.annotation: payload['annotations'] = getAnnotations(args) if args.param: payload['parameters'] = getParams(args) if args.shared: self.addPublish(payload, args) return self.put(args, props, update, json.dumps(payload))
def create(self, args, props, update): annotations = getAnnotations(args) parameters = getParams(args) createFeed = 'feed' in args and args.feed if createFeed: annotations.append(getParam('feed', args.feed)) # if creating a trigger feed, parameters are passed to # the feed action, not the trigger parameters = [] payload = {} if annotations: payload['annotations'] = annotations if parameters: payload['parameters'] = parameters if args.shared: self.addPublish(payload, args) putResponse = self.httpPut(args, props, update, json.dumps(payload)) if putResponse.status == httplib.OK and createFeed: return self.createFeed(args, props, putResponse) else: return self.putResponse(putResponse, update)
def create(self, args, props, update): exe = self.getExec(args, props) validExe = exe is not None and 'kind' in exe if update or validExe: # if create action, then exe must be valid payload = {} if args.annotation: payload['annotations'] = getAnnotations(args) if args.param: payload['parameters'] = getParams(args) # API will accept limits == {} as limits not specified on an update if args.timeout or args.memory: payload['limits'] = self.getLimits(args) if validExe: payload['exec'] = exe if args.shared: self.addPublish(payload, args) return self.put(args, props, update, json.dumps(payload)) else: if not args.copy: print >> sys.stderr, 'the artifact "%s" is not a valid file. If this is a docker image, use --docker.' % args.artifact else: print >> sys.stderr, 'the action "%s" does not exit, is malformed, or your are not entitled to it.' % args.artifact return 2