コード例 #1
0
    def testGetMethods(self):
        # Flat path resource
        c = registry.GetMethods('compute.instances')
        self.assertGreater(len(c), 10)
        c = registry.GetMethods('compute.instances', 'v1')
        self.assertGreater(len(c), 10)

        with self.assertRaises(registry.UnknownAPIError):
            registry.GetMethods('junk.foo')
        with self.assertRaises(registry.UnknownCollectionError):
            registry.GetMethods('compute.junk')
        with self.assertRaises(registry.UnknownAPIVersionError):
            registry.GetMethods('compute.instances', 'junk')
コード例 #2
0
ファイル: lint.py プロジェクト: sarahdactyl71/gneiss-rocks
  def Run(self, args):
    if args.api_version and not args.api:
      raise exceptions.RequiredArgumentException(
          '--api',
          'The --api-version flag can only be specified when using the --api '
          'flag.')

    collections = registry.GetAPICollections(api_name=args.api,
                                             api_version=args.api_version)
    results = []
    for c in collections:
      methods = registry.GetMethods(c.full_name, api_version=c.api_version)
      if not methods:
        # Synthetic collection
        continue

      list_methods = [m for m in methods if m.IsList()]
      if list_methods:
        method = list_methods[0]
        results.append({'collection': c.full_name,
                        'has_list': True,
                        'resource_arg': bool(method.RequestCollection()),
                        'flattened': bool(method.ListItemField()),
                        'pageable': method.IsPageableList(),
                        'page_size': bool(method.BatchPageSizeField())})
      else:
        results.append({'collection': c.full_name, 'has_list': False})

    # Filter out anything that is fully within spec.
    results = [r for r in results if not (r['has_list'] and
                                          r['resource_arg'] and
                                          r['flattened'] and
                                          r['pageable'] and
                                          r['page_size'])]
    return results
コード例 #3
0
    def Run(self, args):
        if not args.collection:
            collections = [
                registry.GetAPICollections(api.name, api.version)
                for api in registry.GetAllAPIs()
            ]
            collections = list(itertools.chain.from_iterable(collections))
            methods = [
                registry.GetMethods(collection.full_name,
                                    api_version=collection.api_version)
                for collection in collections
            ]
            methods = list(itertools.chain.from_iterable(methods))
            return methods

        return registry.GetMethods(args.collection,
                                   api_version=args.api_version)
コード例 #4
0
 def Run(self, args):
     return registry.GetMethods(args.collection,
                                api_version=args.api_version)
コード例 #5
0
ファイル: flags.py プロジェクト: saranraju90/multik8s
def MethodCompleter(prefix, parsed_args, **_):
    del prefix
    collection = getattr(parsed_args, 'collection', None)
    if not collection:
        return []
    return [m.name for m in registry.GetMethods(collection)]