Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1994 from 0xDagal/add_page_token
Browse files Browse the repository at this point in the history
Add page token to ListOption
  • Loading branch information
svanharmelen authored Aug 24, 2024
2 parents e57ef95 + b91bf08 commit b04c46a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 6 additions & 5 deletions gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,16 @@ type Client struct {
// ListOptions specifies the optional parameters to various List methods that
// support pagination.
type ListOptions struct {
// For offset-based paginated result sets, page of results to retrieve.
Page int `url:"page,omitempty" json:"page,omitempty"`
// For keyset-based paginated result sets, the value must be `"keyset"`
Pagination string `url:"pagination,omitempty" json:"pagination,omitempty"`
// For offset-based and keyset-based paginated result sets, the number of results to include per page.
PerPage int `url:"per_page,omitempty" json:"per_page,omitempty"`

// For offset-based paginated result sets, page of results to retrieve.
Page int `url:"page,omitempty" json:"page,omitempty"`
// For keyset-based paginated result sets, tree record ID at which to fetch the next page.
PageToken string `url:"page_token,omitempty" json:"page_token,omitempty"`
// For keyset-based paginated result sets, name of the column by which to order
OrderBy string `url:"order_by,omitempty" json:"order_by,omitempty"`
// For keyset-based paginated result sets, the value must be `"keyset"`
Pagination string `url:"pagination,omitempty" json:"pagination,omitempty"`
// For keyset-based paginated result sets, sort order (`"asc"`` or `"desc"`)
Sort string `url:"sort,omitempty" json:"sort,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ type Project struct {
MergeRequestDefaultTargetSelf bool `json:"mr_default_target_self"`
ModelExperimentsAccessLevel AccessControlValue `json:"model_experiments_access_level"`
ModelRegistryAccessLevel AccessControlValue `json:"model_registry_access_level"`
PreReceiveSecretDetectionEnabled bool `json:"pre_receive_secret_detection_enabled"`
PreReceiveSecretDetectionEnabled bool `json:"pre_receive_secret_detection_enabled"`

// Deprecated: Use EmailsEnabled instead
EmailsDisabled bool `json:"emails_disabled"`
Expand Down
12 changes: 12 additions & 0 deletions repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ func TestRepositoriesService_ListTree(t *testing.T) {
},
}

lto := ListTreeOptions{
ListOptions: ListOptions{
PerPage: 1,
PageToken: "a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba",
},
}

tns, resp, err := client.Repositories.ListTree(1, nil)
require.NoError(t, err)
require.NotNil(t, resp)
Expand All @@ -56,6 +63,11 @@ func TestRepositoriesService_ListTree(t *testing.T) {
require.Error(t, err)
require.Nil(t, tns)
require.Equal(t, http.StatusNotFound, resp.StatusCode)

tns, resp, err = client.Repositories.ListTree(1, &lto)
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, want, tns)
}

func TestRepositoriesService_Blob(t *testing.T) {
Expand Down

0 comments on commit b04c46a

Please sign in to comment.