def Handle(self, unused_args, token=None): router_methods = self.router.__class__.GetAnnotatedMethods() result = ApiListApiMethodsResult() for router_method in itervalues(router_methods): api_method = ApiMethod( name=router_method.name, category=router_method.category, doc=router_method.doc, http_route=router_method.http_methods[-1][1], http_methods=[router_method.http_methods[-1][0]]) if router_method.args_type: api_method.args_type_descriptor = ( api_value_renderers.BuildTypeDescriptor( router_method.args_type)) if router_method.result_type: if router_method.result_type == router_method.BINARY_STREAM_RESULT_TYPE: api_method.result_kind = api_method.ResultKind.BINARY_STREAM else: api_method.result_kind = api_method.ResultKind.VALUE api_method.result_type_descriptor = ( api_value_renderers.BuildTypeDescriptor( router_method.result_type)) else: api_method.result_kind = api_method.ResultKind.NONE result.items.append(api_method) return result
def Handle(self, unused_args, token=None): result = ApiListRDFValueDescriptorsResult() all_types = _GetAllTypes() for cls_name in sorted(all_types): cls = all_types[cls_name] result.items.append(api_value_renderers.BuildTypeDescriptor(cls)) return result
def Handle(self, unused_args, context=None): result = ApiListRDFValueDescriptorsResult() all_types = _GetAllTypes() for cls_name in sorted(all_types): cls = all_types[cls_name] result.items.append(api_value_renderers.BuildTypeDescriptor(cls)) # TODO(user): remove this special case as soon as Python 3 migration # is done. This is needed, since in Python 2 "bytes" is an alias # to "str" and doesn't exist as a standalone type. bytes_descriptor = api_value_renderers.ApiRDFValueDescriptor( name="bytes", parents=["bytes", "object"], doc="", kind=api_value_renderers.ApiRDFValueDescriptor.Kind.PRIMITIVE, ) result.items.append(bytes_descriptor) # TODO(user): remove this special case as soon as Python 3 migration # is done. This is needed, since in Python 3 "unicode" is an alias to # "str" and doesn't exist as a standalone type. unicode_descriptor = api_value_renderers.ApiRDFValueDescriptor( name="unicode", parents=["unicode", "object"], doc="", kind=api_value_renderers.ApiRDFValueDescriptor.Kind.PRIMITIVE, ) result.items.append(unicode_descriptor) # TODO(user): remove this special case as soon as Python 3 migration # is done. This is needed, since in Python 3 "long" is an alias to # "int" and doesn't exist as a standalone type. unicode_descriptor = api_value_renderers.ApiRDFValueDescriptor( name="long", parents=["long", "object"], doc="", kind=api_value_renderers.ApiRDFValueDescriptor.Kind.PRIMITIVE, ) result.items.append(unicode_descriptor) return result
def Handle(self, args, token=None): _ = token rdfvalue_class = _GetAllTypes()[args.type] return api_value_renderers.BuildTypeDescriptor(rdfvalue_class)