Example #1
0
 def _create_client(self, name, methods):
     class_attributes = {}
     for method in methods:
         for method_name in [
                 utils.snake_case(str(method['name'])),
                 utils.snake_case(str(method['idName']))
         ]:
             class_attributes.update(
                 {method_name: self._create_method(method_name, method)})
     bases = [object]
     cls = type(name, tuple(bases), class_attributes)
     return cls
Example #2
0
 def _create_client(self, name, methods):
     class_attributes = {}
     for _name, method in methods.items():
         method_name = utils.snake_case(str(_name))
         class_attributes.update({method_name: self._create_method(method_name, method)})
     bases = [object]
     cls = type(name, tuple(bases), class_attributes)
     return cls
Example #3
0
 def _create_classes(self, definitions):
     class_attributes = defaultdict(dict)
     for path, path_object in definitions["paths"].items():
         for method, method_object in path_object.items():
             _cls_name, _id_name = method_object.get("operationId").split(
                 "/")
             cls_name = utils.snake_case(str(_cls_name))
             method_id_name = utils.snake_case(str(_id_name))
             method_name = utils.snake_case(
                 str(method_object.get("summary")))
             class_attributes[cls_name].update({
                 method_id_name:
                 self._create_method(method_id_name, method_object, method,
                                     path),
                 method_name:
                 self._create_method(method_name, method_object, method,
                                     path),
             })
     return class_attributes
Example #4
0
 def _get_class_methods(self, method_object, method, path):
     cls_name, method_id_name = self._get_names_from_operation_id(
         method_object)
     method_name = utils.snake_case(str(method_object.get("summary")))
     methods = {
         method_id_name:
         self._create_method(method_id_name, method_object, method, path),
         method_name:
         self._create_method(method_name, method_object, method, path),
     }
     methods.update(self._get_deprecated_methods(methods, method_object))
     return cls_name, methods
Example #5
0
 def _create(self, definitions):
     for name, value in definitions.items():
         cls_name = utils.snake_case(name)
         client = self._create_client(cls_name, value)
         setattr(self, cls_name, client)
Example #6
0
 def _get_names_from_operation_id(self, _object):
     _cls_name, _id_name = _object.get("operationId").split("/")
     cls_name = utils.snake_case(str(_cls_name))
     method_id_name = utils.snake_case(str(_id_name))
     return cls_name, method_id_name