Пример #1
0
def test_list_projects_paginated(mock_raw_list_projects):
    client = _SynchronousFlyteClient(url="a.b.com", insecure=True)
    client.list_projects_paginated(limit=100, token="")
    project_list_request = _project_pb2.ProjectListRequest(limit=100,
                                                           token="",
                                                           filters=None,
                                                           sort_by=None)
    mock_raw_list_projects.assert_called_with(
        project_list_request=project_list_request)
Пример #2
0
def test_list_projects_paginated(mock_channel, mock_admin):
    client = _RawSynchronousFlyteClient(url="a.b.com", insecure=True)
    project_list_request = _project_pb2.ProjectListRequest(limit=100,
                                                           token="",
                                                           filters=None,
                                                           sort_by=None)
    client.list_projects(project_list_request)
    mock_admin.AdminServiceStub().ListProjects.assert_called_with(
        project_list_request, metadata=None)
Пример #3
0
def test_list_projects_paginated(mock_raw_list_projects):
    client = _SynchronousFlyteClient(
        PlatformConfig.for_endpoint("a.b.com", True))
    client.list_projects_paginated(limit=100, token="")
    project_list_request = _project_pb2.ProjectListRequest(limit=100,
                                                           token="",
                                                           filters=None,
                                                           sort_by=None)
    mock_raw_list_projects.assert_called_with(
        project_list_request=project_list_request)
Пример #4
0
    def list_projects_paginated(self,
                                limit=100,
                                token=None,
                                filters=None,
                                sort_by=None):
        """
        This returns a page of projects.

        .. note ::

            This is a paginated API.  Use the token field in the request to specify a page offset token.
            The user of the API is responsible for providing this token.

        .. note ::

            If entries are added to the database between requests for different pages, it is possible to receive
            entries on the second page that also appeared on the first.

        :param int limit: [Optional] The maximum number of entries to return.  Must be greater than 0.  The maximum
            page size is determined by the Flyte Admin Service configuration.  If limit is greater than the maximum
            page size, an exception will be raised.
        :param Text token: [Optional] If specified, this specifies where in the rows of results to skip before reading.
            If you previously retrieved a page response with token="foo" and you want the next page,
            specify token="foo". Please see the notes for this function about the caveats of the paginated API.
        :param list[flytekit.models.filters.Filter] filters: [Optional] If specified, the filters will be applied to
            the query.  If the filter is not supported, an exception will be raised.
        :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
        :raises grpc.RpcError:
        :rtype: (list[flytekit.models.Project], Text)
        """
        projects = super(SynchronousFlyteClient, self).list_projects(
            project_list_request=_project_pb2.ProjectListRequest(
                limit=limit,
                token=token,
                filters=_filters.FilterList(filters or []).to_flyte_idl(),
                sort_by=None if sort_by is None else sort_by.to_flyte_idl(),
            ))
        return (
            [_project.Project.from_flyte_idl(pb) for pb in projects.projects],
            _six.text_type(projects.token),
        )