Skip to content

Commit c59b996

Browse files
authored
Add GET & DELETE functions for Repository Pipeline Key Pair (ktrysmt#221)
And updated `PipelineKeyPair` struct to match response from Bitbucket's API.
1 parent 3a30edc commit c59b996

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

repository.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ type PipelineVariable struct {
120120

121121
type PipelineKeyPair struct {
122122
Type string
123-
Uuid string
124-
PublicKey string
125-
PrivateKey string
123+
Public_key string
126124
}
127125

128126
type PipelineBuildNumber struct {
@@ -726,6 +724,17 @@ func (r *Repository) UpdatePipelineVariable(opt *RepositoryPipelineVariableOptio
726724
return decodePipelineVariableRepository(response)
727725
}
728726

727+
func (r *Repository) GetPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error) {
728+
urlStr := r.c.requestUrl("/repositories/%s/%s/pipelines_config/ssh/key_pair", rpkpo.Owner, rpkpo.RepoSlug)
729+
730+
response, err := r.c.execute("GET", urlStr, "")
731+
if err != nil {
732+
return nil, err
733+
}
734+
735+
return decodePipelineKeyPairRepository(response)
736+
}
737+
729738
func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error) {
730739
data, err := r.buildPipelineKeyPairBody(rpkpo)
731740
if err != nil {
@@ -741,6 +750,11 @@ func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions)
741750
return decodePipelineKeyPairRepository(response)
742751
}
743752

753+
func (r *Repository) DeletePipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (interface{}, error) {
754+
urlStr := r.c.requestUrl("/repositories/%s/%s/pipelines_config/ssh/key_pair", rpkpo.Owner, rpkpo.RepoSlug)
755+
return r.c.execute("DELETE", urlStr, "")
756+
}
757+
744758
func (r *Repository) UpdatePipelineBuildNumber(rpbno *RepositoryPipelineBuildNumberOptions) (*PipelineBuildNumber, error) {
745759
data, err := r.buildPipelineBuildNumberBody(rpbno)
746760
if err != nil {

0 commit comments

Comments
 (0)