Beispiel #1
0
    def get_links(self, instance):
        """
        Translate the `links` property to a custom array of Hyperlink values.

        Parameters
        ----------
        instance : Target Obj instance

        Returns
        -------
        Hyperlink url for Target detail API endpoint
        """
        list_of_actions = action_checker(self.context.get('target_name'))
        # Build a list of endpoint_actions and compare with list_of_actions
        if self.context.get('target_name') == 'github':
            github_endpoint_actions = ['resource_download']
            resource_actions = list_intersection(list_of_actions,
                                                 github_endpoint_actions)
        else:
            endpoint_actions = [
                'resource_download',
                'resource_upload',
                'resource_transfer_in',
            ]
            resource_actions = list_intersection(list_of_actions,
                                                 endpoint_actions)

        links = link_builder(self, instance, resource_actions)

        return links
Beispiel #2
0
    def get_actions(self, instance):
        """
        Translate the `actions` property to a custom array of `action names`.

        Parameters
        ----------
        instance : Target Obj instance

        Returns
        -------
        Array of possible actions for the endpoint.
        """
        list_of_actions = action_checker(self.context.get('target_name'))
        action_list = []
        if 'resource_transfer_out' in list_of_actions:
            action_list.append('Transfer')

        return action_list
Beispiel #3
0
    def get_links(self, instance):
        """
        Translate the `links` property to a custom array of Hyperlink values.

        Parameters
        ----------
        instance : Target Obj instance

        Returns
        -------
        Hyperlink url for Target detail API endpoint
        """
        list_of_actions = action_checker(self.context.get('target_name'))
        # Build a list of endpoint_actions and compare with list of actions
        resources_actions = list_intersection(list_of_actions, ['resource_detail'])

        links = link_builder(self, instance, resources_actions)

        return links
Beispiel #4
0
    def get_links(self, instance):
        """
        Translate the `links` property to a custom array of Hyperlink values.

        Parameters
        ----------
        instance : Target Obj instance

        Returns
        -------
        A list of hyperlink urls for Target detail API endpoint
        """
        list_of_actions = action_checker(instance['name'])
        # Build a list of endpoint_actions to compare with list of actions
        endpoint_actions = [
            'resource_collection', 'resource_upload', 'resource_transfer_in'
        ]
        resources_actions = list_intersection(list_of_actions,
                                              endpoint_actions)

        links = link_builder(self, instance, resources_actions)

        return links