def _add_model_driven_method(self, section, method_name): service_model = self._client.meta.service_model operation_name = self._client.meta.method_to_api_mapping[method_name] operation_model = service_model.operation_model(operation_name) example_prefix = 'response = client.%s' % method_name document_model_driven_method( section, method_name, operation_model, event_emitter=self._client.meta.events, method_description=operation_model.documentation, example_prefix=example_prefix, ) # Add the shared examples shared_examples = self._shared_examples.get(operation_name) if shared_examples: document_shared_examples( section, operation_model, example_prefix, shared_examples)
def _add_model_driven_method(self, section, method_name): service_model = self._client.meta.service_model operation_name = self._client.meta.method_to_api_mapping[method_name] operation_model = service_model.operation_model(operation_name) example_prefix = 'response = client.%s' % method_name document_model_driven_method( section, method_name, operation_model, event_emitter=self._client.meta.events, method_description=operation_model.documentation, example_prefix=example_prefix, ) # Add the shared examples shared_examples = self._shared_examples.get(operation_name) if shared_examples: document_shared_examples(section, operation_model, example_prefix, shared_examples)
def document_wait_method(section, waiter_name, event_emitter, service_model, service_waiter_model, include_signature=True): """Documents a the wait method of a waiter :param section: The section to write to :param waiter_name: The name of the waiter :param event_emitter: The event emitter to use to emit events :param service_model: The service model :param service_waiter_model: The waiter model associated to the service :param include_signature: Whether or not to include the signature. It is useful for generating docstrings. """ waiter_model = service_waiter_model.get_waiter(waiter_name) operation_model = service_model.operation_model(waiter_model.operation) wait_description = ( 'Polls :py:meth:`{0}.Client.{1}` every {2} ' 'seconds until a successful state is reached. An error is ' 'returned after {3} failed checks.'.format( get_service_module_name(service_model), xform_name(waiter_model.operation), waiter_model.delay, waiter_model.max_attempts)) document_model_driven_method(section, 'wait', operation_model, event_emitter=event_emitter, method_description=wait_description, example_prefix='waiter.wait', document_output=False, include_signature=include_signature)
def document_paginate_method(section, paginator_name, event_emitter, service_model, paginator_config, include_signature=True): """Documents the paginate method of a paginator :param section: The section to write to :param paginator_name: The name of the paginator. It is snake cased. :param event_emitter: The event emitter to use to emit events :param service_model: The service model :param paginator_config: The paginator config associated to a particular paginator. :param include_signature: Whether or not to include the signature. It is useful for generating docstrings. """ # Retrieve the operation model of the underlying operation. operation_model = service_model.operation_model(paginator_name) # Add representations of the request and response parameters # we want to include in the description of the paginate method. # These are parameters we expose via the kscore interface. pagination_config_members = OrderedDict() pagination_config_members['MaxItems'] = DocumentedShape( name='MaxItems', type_name='integer', documentation=('<p>The total number of items to return. If the total ' 'number of items available is more than the value ' 'specified in max-items then a <code>NextToken</code> ' 'will be provided in the output that you can use to ' 'resume pagination.</p>')) pagination_config_members['PageSize'] = DocumentedShape( name='PageSize', type_name='integer', documentation='<p>The size of each page.<p>') pagination_config_members['StartingToken'] = DocumentedShape( name='StartingToken', type_name='string', documentation=('<p>A token to specify where to start paginating. ' 'This is the <code>NextToken</code> from a previous ' 'response.</p>')) kscore_pagination_params = [ DocumentedShape( name='PaginationConfig', type_name='structure', documentation=( '<p>A dictionary that provides parameters to control ' 'pagination.</p>'), members=pagination_config_members) ] kscore_pagination_response_params = [ DocumentedShape(name='NextToken', type_name='string', documentation=('<p>A token to resume pagination.</p>')) ] service_pagination_params = [] # Add the normal input token of the method to a list # of input paramters that we wish to hide since we expose our own. if isinstance(paginator_config['input_token'], list): service_pagination_params += paginator_config['input_token'] else: service_pagination_params.append(paginator_config['input_token']) # Hide the limit key in the documentation. if paginator_config.get('limit_key', None): service_pagination_params.append(paginator_config['limit_key']) # Hide the output tokens in the documentation. service_pagination_response_params = [] if isinstance(paginator_config['output_token'], list): service_pagination_response_params += paginator_config['output_token'] else: service_pagination_response_params.append( paginator_config['output_token']) paginate_description = ( 'Creates an iterator that will paginate through responses ' 'from :py:meth:`{0}.Client.{1}`.'.format( get_service_module_name(service_model), xform_name(paginator_name))) document_model_driven_method( section, 'paginate', operation_model, event_emitter=event_emitter, method_description=paginate_description, example_prefix='response_iterator = paginator.paginate', include_input=kscore_pagination_params, include_output=kscore_pagination_response_params, exclude_input=service_pagination_params, exclude_output=service_pagination_response_params, include_signature=include_signature)
def _write_docstring(self, *args, **kwargs): document_model_driven_method(*args, **kwargs)
def document_paginate_method(section, paginator_name, event_emitter, service_model, paginator_config, include_signature=True): """Documents the paginate method of a paginator :param section: The section to write to :param paginator_name: The name of the paginator. It is snake cased. :param event_emitter: The event emitter to use to emit events :param service_model: The service model :param paginator_config: The paginator config associated to a particular paginator. :param include_signature: Whether or not to include the signature. It is useful for generating docstrings. """ # Retrieve the operation model of the underlying operation. operation_model = service_model.operation_model( paginator_name) # Add representations of the request and response parameters # we want to include in the description of the paginate method. # These are parameters we expose via the kscore interface. pagination_config_members = OrderedDict() pagination_config_members['MaxItems'] = DocumentedShape( name='MaxItems', type_name='integer', documentation=( '<p>The total number of items to return. If the total ' 'number of items available is more than the value ' 'specified in max-items then a <code>NextToken</code> ' 'will be provided in the output that you can use to ' 'resume pagination.</p>')) pagination_config_members['PageSize'] = DocumentedShape( name='PageSize', type_name='integer', documentation='<p>The size of each page.<p>') pagination_config_members['StartingToken'] = DocumentedShape( name='StartingToken', type_name='string', documentation=( '<p>A token to specify where to start paginating. ' 'This is the <code>NextToken</code> from a previous ' 'response.</p>')) kscore_pagination_params = [ DocumentedShape( name='PaginationConfig', type_name='structure', documentation=( '<p>A dictionary that provides parameters to control ' 'pagination.</p>'), members=pagination_config_members) ] kscore_pagination_response_params = [ DocumentedShape( name='NextToken', type_name='string', documentation=( '<p>A token to resume pagination.</p>')) ] service_pagination_params = [] # Add the normal input token of the method to a list # of input paramters that we wish to hide since we expose our own. if isinstance(paginator_config['input_token'], list): service_pagination_params += paginator_config['input_token'] else: service_pagination_params.append(paginator_config['input_token']) # Hide the limit key in the documentation. if paginator_config.get('limit_key', None): service_pagination_params.append(paginator_config['limit_key']) # Hide the output tokens in the documentation. service_pagination_response_params = [] if isinstance(paginator_config['output_token'], list): service_pagination_response_params += paginator_config[ 'output_token'] else: service_pagination_response_params.append(paginator_config[ 'output_token']) paginate_description = ( 'Creates an iterator that will paginate through responses ' 'from :py:meth:`{0}.Client.{1}`.'.format( get_service_module_name(service_model), xform_name(paginator_name)) ) document_model_driven_method( section, 'paginate', operation_model, event_emitter=event_emitter, method_description=paginate_description, example_prefix='response_iterator = paginator.paginate', include_input=kscore_pagination_params, include_output=kscore_pagination_response_params, exclude_input=service_pagination_params, exclude_output=service_pagination_response_params, include_signature=include_signature )
def _write_docstring(self, *args, **kwargs): document_model_driven_method(*args, **kwargs)