Exemplo n.º 1
0
    def get_one(self, project_group_id):
        """Retrieve information about the given project group.

        :param project_group_id: Project group id.
        """

        group = project_groups.project_group_get(project_group_id)
        if not group:
            raise exc.NotFound(
                _("Project Group %s not found") % project_group_id)

        return wmodels.ProjectGroup.from_db_model(group)
Exemplo n.º 2
0
    def get_one(self, project_group_id):
        """Retrieve information about the given project group.

        :param project_group_id: Project group id.
        """

        group = project_groups.project_group_get(project_group_id)
        if not group:
            raise exc.NotFound(_("Project Group %s not found")
                               % project_group_id)

        return wmodels.ProjectGroup.from_db_model(group)
Exemplo n.º 3
0
    def get(self,
            marker=None,
            offset=None,
            limit=None,
            name=None,
            title=None,
            subscriber_id=None,
            sort_field='id',
            sort_dir='asc'):
        """Retrieve a list of projects groups.

        :param marker: The resource id where the page should begin.
        :param offset: The offset to start the page at.
        :param limit: The number of project groups to retrieve.
        :param name: A string to filter the name by.
        :param title: A string to filter the title by.
        :param subscriber_id: The ID of a subscriber to filter by.
        :param sort_field: The name of the field to sort on.
        :param sort_dir: Sort direction for results (asc, desc).
        """

        if limit is not None:
            limit = max(0, limit)

        # Resolve the marker record.
        marker_group = None
        if marker is not None:
            marker_group = project_groups.project_group_get(marker)

        groups = project_groups.project_group_get_all(
            marker=marker_group,
            offset=offset,
            limit=limit,
            name=name,
            title=title,
            subscriber_id=subscriber_id,
            sort_field=sort_field,
            sort_dir=sort_dir)

        group_count = project_groups.project_group_get_count(
            name=name, title=title, subscriber_id=subscriber_id)

        # Apply the query response headers.
        if limit:
            response.headers['X-Limit'] = str(limit)
        response.headers['X-Total'] = str(group_count)
        if marker_group:
            response.headers['X-Marker'] = str(marker_group.id)
        if offset is not None:
            response.headers['X-Offset'] = str(offset)

        return [wmodels.ProjectGroup.from_db_model(group) for group in groups]
Exemplo n.º 4
0
    def get(self, project_group_id):
        """Get projects inside a project group.

        :param project_group_id: An ID of the project group.
        """

        project_group = project_groups.project_group_get(project_group_id)

        if not project_group:
            raise exc.NotFound(_("Project Group %s not found")
                               % project_group_id)

        return [wmodels.Project.from_db_model(project)
                for project in project_group.projects]
Exemplo n.º 5
0
    def get(self, marker=None, offset=None, limit=None, name=None, title=None,
            subscriber_id=None, sort_field='id', sort_dir='asc'):
        """Retrieve a list of projects groups.

        Example::

          curl https://my.example.org/api/v1/project_groups

        :param marker: The resource id where the page should begin.
        :param offset: The offset to start the page at.
        :param limit: The number of project groups to retrieve.
        :param name: A string to filter the name by.
        :param title: A string to filter the title by.
        :param subscriber_id: The ID of a subscriber to filter by.
        :param sort_field: The name of the field to sort on.
        :param sort_dir: Sort direction for results (asc, desc).
        """

        if limit is not None:
            limit = max(0, limit)

        # Resolve the marker record.
        marker_group = None
        if marker is not None:
            marker_group = project_groups.project_group_get(marker)

        groups = project_groups.project_group_get_all(
            marker=marker_group,
            offset=offset,
            limit=limit,
            name=name,
            title=title,
            subscriber_id=subscriber_id,
            sort_field=sort_field,
            sort_dir=sort_dir)

        group_count = project_groups.project_group_get_count(
            name=name, title=title, subscriber_id=subscriber_id)

        # Apply the query response headers.
        if limit:
            response.headers['X-Limit'] = str(limit)
        response.headers['X-Total'] = str(group_count)
        if marker_group:
            response.headers['X-Marker'] = str(marker_group.id)
        if offset is not None:
            response.headers['X-Offset'] = str(offset)

        return [wmodels.ProjectGroup.from_db_model(group) for group in groups]
Exemplo n.º 6
0
    def get_one_by_id(self, project_group_id):
        """Retrieve information about the given project group.

        Example::

          curl https://my.example.org/api/v1/project_groups/55

        :param project_group_id: Project group id.
        """

        group = project_groups.project_group_get(project_group_id)
        if not group:
            raise exc.NotFound(_("Project Group %s not found")
                               % project_group_id)

        return wmodels.ProjectGroup.from_db_model(group)
Exemplo n.º 7
0
    def get(self, project_group_id):
        """Get projects inside a project group.

        :param project_group_id: An ID of the project group.
        """

        project_group = project_groups.project_group_get(project_group_id)

        if not project_group:
            raise exc.NotFound(
                _("Project Group %s not found") % project_group_id)

        return [
            wmodels.Project.from_db_model(project)
            for project in project_group.projects
        ]
Exemplo n.º 8
0
    def get(self, project_group_id):
        """Get projects inside a project group.

        Example::

          curl https://my.example.org/api/v1/project_groups/55/projects

        :param project_group_id: An ID or name of the project group.
        """

        if _is_int(project_group_id):
            group = project_groups.project_group_get(int(project_group_id))
        else:
            group = project_groups.project_group_get_by_name(project_group_id)

        if not group:
            raise exc.NotFound(_("Project Group %s not found")
                               % project_group_id)

        return [wmodels.Project.from_db_model(project)
                for project in group.projects]
Exemplo n.º 9
0
    def get(self, marker=None, limit=None, name=None, title=None,
            sort_field='id', sort_dir='asc'):
        """Retrieve a list of projects groups.

        :param marker: The resource id where the page should begin.
        :param limit: The number of project groups to retrieve.
        :param name: A string to filter the name by.
        :param title: A string to filter the title by.
        :param sort_field: The name of the field to sort on.
        :param sort_dir: Sort direction for results (asc, desc).
        """

        if limit is not None:
            limit = max(0, limit)

        # Resolve the marker record.
        marker_group = project_groups.project_group_get(marker)

        groups = project_groups.project_group_get_all(marker=marker_group,
                                                      limit=limit,
                                                      name=name,
                                                      title=title,
                                                      sort_field=sort_field,
                                                      sort_dir=sort_dir)

        group_count = project_groups.project_group_get_count(name=name,
                                                             title=title)

        # Apply the query response headers.
        if limit:
            response.headers['X-Limit'] = str(limit)
        response.headers['X-Total'] = str(group_count)
        if marker_group:
            response.headers['X-Marker'] = str(marker_group.id)

        return [wmodels.ProjectGroup.from_db_model(group) for group in groups]