From 681989dbbb53d685c96a34256cdd591717f447a8 Mon Sep 17 00:00:00 2001 From: Lynwee Date: Mon, 16 Oct 2023 20:45:07 +0800 Subject: [PATCH] feat(pagerduty): search remote scope by keyword (#6255) * feat(pagerduty): search remote scope by keyword * feat(pagerduty): add `createdAt` field --- backend/plugins/pagerduty/api/remote.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/plugins/pagerduty/api/remote.go b/backend/plugins/pagerduty/api/remote.go index 056d09e3a63..86577a0858c 100644 --- a/backend/plugins/pagerduty/api/remote.go +++ b/backend/plugins/pagerduty/api/remote.go @@ -22,6 +22,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "github.com/apache/incubator-devlake/core/models/common" "net/http" "net/url" "strconv" @@ -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) @@ -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) @@ -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) {