예제 #1
0
    def _create_api_method(self, py_operation_name, operation_name,
                           service_model):
        def _api_call(self, *args, **kwargs):
            # We're accepting *args so that we can give a more helpful
            # error message than TypeError: _api_call takes exactly
            # 1 argument.
            if args:
                raise TypeError("%s() only accepts keyword arguments." %
                                py_operation_name)
            # The "self" in this scope is referring to the BaseClient.
            return self._make_api_call(operation_name, kwargs)

        _api_call.__name__ = str(py_operation_name)

        # Add the docstring to the client method
        operation_model = service_model.operation_model(operation_name)
        docstring = ClientMethodDocstring(
            operation_model=operation_model,
            method_name=operation_name,
            event_emitter=self._event_emitter,
            method_description=operation_model.documentation,
            example_prefix='response = client.%s' % py_operation_name,
            include_signature=False)
        _api_call.__doc__ = docstring
        return _api_call
예제 #2
0
 def render_operation(self):
     # try and reuse botocore's sphinx doc infrastructure.
     method_doc = ClientMethodDocstring(
         operation_model=self.op,
         method_name=self.op.name,
         event_emitter=hooks.HierarchicalEmitter(),
         method_description=self.op.documentation,
         example_prefix="client.%s" % xform_name(self.op.name),
         include_signature=False,
     )
     return self._render_docutils(method_doc)
예제 #3
0
 def render_operation(self, service_change, op_name):
     # try and reuse botocore's sphinx doc infrastructure.
     m = self._get_service_model(service_change)
     if m is None:
         log.error("couldnt find model %s", service_change)
         return ""
     opm = m.operation_model(op_name)
     method_doc = ClientMethodDocstring(
         operation_model=opm,
         method_name=opm.name,
         event_emitter=hooks.HierarchicalEmitter(),
         method_description=opm.documentation,
         example_prefix="client.%s" % xform_name(opm.name),
         include_signature=False,
     )
     return self._render_docutils(method_doc)
예제 #4
0
 def test_use_correct_docstring_writer(self):
     with mock.patch('botocore.docs.docstring'
                     '.document_model_driven_method') as mock_writer:
         docstring = ClientMethodDocstring()
         str(docstring)
         self.assertTrue(mock_writer.called)