Skip to content

Commit f42fe44

Browse files
committed
feat: adds GetRepositoryPullRequests function for getting pull requests at a repository level
1 parent 6e30c57 commit f42fe44

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Class | Method | HTTP request | Description
116116
*DefaultApi* | [**GetRepositoryHook_0**](docs/DefaultApi.md#getrepositoryhook_0) | **Get** /api/1.0/projects/{projectKey}/settings/hooks/{hookKey} |
117117
*DefaultApi* | [**GetRepositoryHooks**](docs/DefaultApi.md#getrepositoryhooks) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks |
118118
*DefaultApi* | [**GetRepositoryHooks_0**](docs/DefaultApi.md#getrepositoryhooks_0) | **Get** /api/1.0/projects/{projectKey}/settings/hooks |
119+
*DefaultApi* | [**GetRepositoryPullRequests**](docs/DefaultApi.md#getrepositorypullrequests) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests
119120
*DefaultApi* | [**GetRootLevel**](docs/DefaultApi.md#getrootlevel) | **Get** /api/1.0/logs/rootLogger |
120121
*DefaultApi* | [**GetSenderAddress**](docs/DefaultApi.md#getsenderaddress) | **Get** /api/1.0/admin/mail-server/sender-address |
121122
*DefaultApi* | [**GetSettings**](docs/DefaultApi.md#getsettings) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/settings |

default_api_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,48 @@ func TestDefaultApiService_CreatePullRequest(t *testing.T) {
630630
}
631631
}
632632

633+
func TestDefaultApiService_GetRepositoryPullRequests(t *testing.T) {
634+
type fields struct {
635+
client *APIClient
636+
}
637+
tests := []struct {
638+
name string
639+
projectKey string
640+
repositorySlug string
641+
want *APIResponse
642+
updatePullRequestOptions *EditPullRequestOptions
643+
wantErr bool
644+
fields fields
645+
}{
646+
{
647+
projectKey: "test",
648+
repositorySlug: "repoTest",
649+
want: &APIResponse{Message: "Get https://stash.domain.com/rest/api/1.0/projects/test/repos/repoTest/pull-requests: context canceled"},
650+
updatePullRequestOptions: &EditPullRequestOptions{},
651+
wantErr: true,
652+
fields: fields{client: generateConfigFake()},
653+
},
654+
}
655+
for _, tt := range tests {
656+
client := &DefaultApiService{
657+
client: tt.fields.client,
658+
}
659+
t.Run(tt.name, func(t *testing.T) {
660+
got, err := client.GetRepositoryPullRequests(tt.projectKey, tt.repositorySlug, nil)
661+
if (err != nil) != tt.wantErr {
662+
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
663+
return
664+
}
665+
if got != nil {
666+
got.Response = nil
667+
}
668+
if !reflect.DeepEqual(got, tt.want) {
669+
t.Errorf("DefaultApiService.Create() = %v, want %v", got, tt.want)
670+
}
671+
})
672+
}
673+
}
674+
633675
func TestDefaultApiService_UpdatePullRequest(t *testing.T) {
634676
type fields struct {
635677
client *APIClient

docs/DefaultApi.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Method | HTTP request | Description
103103
[**GetRepositoryHook_0**](DefaultApi.md#GetRepositoryHook_0) | **Get** /api/1.0/projects/{projectKey}/settings/hooks/{hookKey} |
104104
[**GetRepositoryHooks**](DefaultApi.md#GetRepositoryHooks) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks |
105105
[**GetRepositoryHooks_0**](DefaultApi.md#GetRepositoryHooks_0) | **Get** /api/1.0/projects/{projectKey}/settings/hooks |
106+
[**GetRepositoryPullRequests**](DefaultApi.md#getrepositorypullrequests) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests
106107
[**GetRootLevel**](DefaultApi.md#GetRootLevel) | **Get** /api/1.0/logs/rootLogger |
107108
[**GetSenderAddress**](DefaultApi.md#GetSenderAddress) | **Get** /api/1.0/admin/mail-server/sender-address |
108109
[**GetSettings**](DefaultApi.md#GetSettings) | **Get** /api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/settings |
@@ -3317,6 +3318,47 @@ No authorization required
33173318

33183319
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
33193320

3321+
# **GetRepositoryPullRequests**
3322+
> GetRepositoryPullRequests(projectKey, repositoryKey, optional)
3323+
3324+
3325+
Retrieve a page of pull requests to or from the specified repository. <p> The authenticated user must have <strong>REPO_READ</strong> permission for the specified repository to call this resource.
3326+
3327+
### Required Parameters
3328+
3329+
Name | Type | Description | Notes
3330+
------------- | ------------- | ------------- | -------------
3331+
**projectKey** | **string** | context for logging, tracing, authentication, etc.
3332+
**repositoryKey** | **string** | optional parameters | nil if no parameters
3333+
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
3334+
3335+
### Optional Parameters
3336+
Optional parameters are passed through a map[string]interface{}.
3337+
3338+
Name | Type | Description | Notes
3339+
------------- | ------------- | ------------- | -------------
3340+
**direction** | **string**| the direction relative to the specified repository. Either INCOMING or OUTGOING. | [default to INCOMING ]
3341+
**at** | **string**| a fully-qualified branch ID to find pull requests to or from, such as {@code refs/heads/master}c | [default to ]
3342+
**state** | **string**| supply ALL to return pull request in any state. If a state is supplied only pull requests in the specified state will be returned. Either OPEN, DECLINED or MERGED | [default to OPEN ]
3343+
**order** | **string**| the order to return pull requests in, either OLDEST (as in: "oldest first") or NEWEST. | [default to NEWEST ]
3344+
**withAttributes** | **boolean**| whether to return additional pull request attributes | [default to true ]
3345+
**withProperties** | **boolean**| whether to return additional pull request properties | [default to true ]
3346+
3347+
### Return type
3348+
3349+
(empty response body)
3350+
3351+
### Authorization
3352+
3353+
No authorization required
3354+
3355+
### HTTP request headers
3356+
3357+
- **Content-Type**: Not defined
3358+
- **Accept**: Not defined
3359+
3360+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
3361+
33203362
# **GetRootLevel**
33213363
> GetRootLevel(ctx, )
33223364

0 commit comments

Comments
 (0)