Skip to content

Commit

Permalink
feat(pagerduty): search remote scope by keyword (apache#6255)
Browse files Browse the repository at this point in the history
* feat(pagerduty): search remote scope by keyword

* feat(pagerduty): add `createdAt` field
  • Loading branch information
d4x1 committed Oct 16, 2023
1 parent b5824ba commit 681989d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions backend/plugins/pagerduty/api/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/core/models/common"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -114,6 +115,11 @@ func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, er
return nil, err
}

search := input.Query.Get("search")
if search != "" {
query.Set("query", search)
}

var res *http.Response
outputBody := &RemoteScopesOutput{}
res, err = apiClient.Get("/services", query, nil)
Expand All @@ -136,6 +142,12 @@ func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, er
Url: service.HtmlUrl,
Id: service.Id,
Name: service.Name,
Scope: common.Scope{
NoPKModel: common.NoPKModel{
CreatedAt: service.CreatedAt,
},
ConnectionId: connection.ID,
},
},
}
outputBody.Children = append(outputBody.Children, child)
Expand Down Expand Up @@ -173,8 +185,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, er
// @Failure 500 {object} shared.ApiBody "Internal Error"
// @Router /plugins/pagerduty/connections/{connectionId}/search-remote-scopes [GET]
func SearchRemoteScopes(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
// Not supported
return &plugin.ApiResourceOutput{Body: nil, Status: http.StatusMethodNotAllowed}, nil
return RemoteScopes(input)
}

func EncodeToPageToken(pageData *PageData) (string, errors.Error) {
Expand Down

0 comments on commit 681989d

Please sign in to comment.