def document_sub_resources(self, section):
     add_resource_type_overview(
         section=section,
         resource_type='Sub-resources',
         description=(
             'Sub-resources are methods that create a new instance of a'
             ' child resource. This resource\'s identifiers get passed'
             ' along to the child.'),
         intro_link='subresources_intro',
     )
     sub_resources = sorted(
         self._resource.meta.resource_model.subresources,
         key=lambda sub_resource: sub_resource.name,
     )
     sub_resources_list = []
     self.member_map['sub-resources'] = sub_resources_list
     for sub_resource in sub_resources:
         sub_resource_section = section.add_new_section(sub_resource.name)
         sub_resources_list.append(sub_resource.name)
         document_sub_resource(
             section=sub_resource_section,
             resource_name=self._resource_name,
             sub_resource_model=sub_resource,
             service_model=self._service_model,
         )
 def _add_attributes(self, section):
     service_model = self._resource.meta.client.meta.service_model
     attributes = {}
     if self._resource.meta.resource_model.shape:
         shape = service_model.shape_for(
             self._resource.meta.resource_model.shape)
         attributes = self._resource.meta.resource_model.get_attributes(
             shape)
     section = section.add_new_section('attributes')
     attribute_list = []
     if attributes:
         add_resource_type_overview(
             section=section,
             resource_type='Attributes',
             description=(
                 'Attributes provide access'
                 ' to the properties of a resource. Attributes are lazy-'
                 'loaded the first time one is accessed via the'
                 ' :py:meth:`load` method.'),
             intro_link='identifiers_attributes_intro')
         self.member_map['attributes'] = attribute_list
     for attr_name in sorted(attributes):
         _, attr_shape = attributes[attr_name]
         attribute_section = section.add_new_section(attr_name)
         attribute_list.append(attr_name)
         document_attribute(
             section=attribute_section,
             service_name=self._service_name,
             resource_name=self._resource_name,
             attr_name=attr_name,
             event_emitter=self._resource.meta.client.meta.events,
             attr_model=attr_shape)
 def document_collections(self, section):
     collections = self._resource.meta.resource_model.collections
     collections_list = []
     add_resource_type_overview(
         section=section,
         resource_type='Collections',
         description=(
             'Collections provide an interface to iterate over and '
             'manipulate groups of resources. '),
         intro_link='guide_collections')
     self.member_map['collections'] = collections_list
     for collection in collections:
         collection_section = section.add_new_section(collection.name)
         collections_list.append(collection.name)
         self._document_collection(collection_section, collection)
 def _add_references(self, section):
     section = section.add_new_section('references')
     references = self._resource.meta.resource_model.references
     reference_list = []
     if references:
         add_resource_type_overview(
             section=section,
             resource_type='References',
             description=(
                 'References are related resource instances that have '
                 'a belongs-to relationship.'),
             intro_link='references_intro')
         self.member_map['references'] = reference_list
     for reference in references:
         reference_section = section.add_new_section(reference.name)
         reference_list.append(reference.name)
         document_reference(section=reference_section,
                            reference_model=reference)
 def _add_identifiers(self, section):
     identifiers = self._resource.meta.resource_model.identifiers
     section = section.add_new_section('identifiers')
     member_list = []
     if identifiers:
         self.member_map['identifiers'] = member_list
         add_resource_type_overview(
             section=section,
             resource_type='Identifiers',
             description=(
                 'Identifiers are properties of a resource that are '
                 'set upon instantation of the resource.'),
             intro_link='identifiers_attributes_intro')
     for identifier in identifiers:
         identifier_section = section.add_new_section(identifier.name)
         member_list.append(identifier.name)
         document_identifier(section=identifier_section,
                             resource_name=self._resource_name,
                             identifier_model=identifier)
Exemple #6
0
 def document_resource_waiters(self, section):
     waiters = self._resource.meta.resource_model.waiters
     add_resource_type_overview(
         section=section,
         resource_type='Waiters',
         description=('Waiters provide an interface to wait for a resource'
                      ' to reach a specific state.'),
         intro_link='waiters_intro')
     waiter_list = []
     self.member_map['waiters'] = waiter_list
     for waiter in waiters:
         waiter_section = section.add_new_section(waiter.name)
         waiter_list.append(waiter.name)
         document_resource_waiter(
             section=waiter_section,
             resource_name=self._resource_name,
             event_emitter=self._resource.meta.client.meta.events,
             service_model=self._service_model,
             resource_waiter_model=waiter,
             service_waiter_model=self._service_waiter_model)
Exemple #7
0
    def document_actions(self, section):
        modeled_actions_list = self._resource_model.actions
        modeled_actions = {}
        for modeled_action in modeled_actions_list:
            modeled_actions[modeled_action.name] = modeled_action
        resource_actions = get_resource_public_actions(
            self._resource.__class__)
        self.member_map['actions'] = sorted(resource_actions)
        add_resource_type_overview(
            section=section,
            resource_type='Actions',
            description=(
                'Actions call operations on resources.  They may '
                'automatically handle the passing in of arguments set '
                'from identifiers and some attributes.'),
            intro_link='actions_intro')

        for action_name in sorted(resource_actions):
            if action_name == 'restore_object':
                continue
            action_section = section.add_new_section(action_name)
            if action_name in ['load', 'reload'] and self._resource_model.load:
                document_load_reload_action(
                    section=action_section,
                    action_name=action_name,
                    resource_name=self._resource_name,
                    event_emitter=self._resource.meta.client.meta.events,
                    load_model=self._resource_model.load,
                    service_model=self._service_model
                )
            elif action_name in modeled_actions:
                document_action(
                    section=action_section,
                    resource_name=self._resource_name,
                    event_emitter=self._resource.meta.client.meta.events,
                    action_model=modeled_actions[action_name],
                    service_model=self._service_model,
                )
            else:
                document_custom_method(
                    action_section, action_name, resource_actions[action_name])