Skip to content

Commit

Permalink
Update as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar authored and jlsherrill committed Dec 12, 2024
1 parent 635cbe0 commit 4294e66
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 78 deletions.
64 changes: 32 additions & 32 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api.SearchModuleStreamsRequest"
"$ref": "#/definitions/api.SearchSnapshotModuleStreamsRequest"
}
},
{
Expand Down Expand Up @@ -4633,37 +4633,6 @@ const docTemplate = `{
}
}
},
"api.SearchModuleStreamsRequest": {
"type": "object",
"required": [
"rpm_names",
"uuids"
],
"properties": {
"rpm_names": {
"description": "List of rpm names to search",
"type": "array",
"items": {
"type": "string"
}
},
"search": {
"description": "Search string to search rpm names",
"type": "string"
},
"sort_by": {
"description": "SortBy sets the sort order of the result",
"type": "string"
},
"uuids": {
"description": "List of snapshot UUIDs to search",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"api.SearchPackageGroupResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -4701,6 +4670,37 @@ const docTemplate = `{
}
}
},
"api.SearchSnapshotModuleStreamsRequest": {
"type": "object",
"required": [
"rpm_names",
"uuids"
],
"properties": {
"rpm_names": {
"description": "List of rpm names to search",
"type": "array",
"items": {
"type": "string"
}
},
"search": {
"description": "Search string to search rpm names",
"type": "string"
},
"sort_by": {
"description": "SortBy sets the sort order of the result",
"type": "string"
},
"uuids": {
"description": "List of snapshot UUIDs to search",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"api.SnapshotCollectionResponse": {
"type": "object",
"properties": {
Expand Down
64 changes: 32 additions & 32 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1063,37 +1063,6 @@
},
"type": "object"
},
"api.SearchModuleStreamsRequest": {
"properties": {
"rpm_names": {
"description": "List of rpm names to search",
"items": {
"type": "string"
},
"type": "array"
},
"search": {
"description": "Search string to search rpm names",
"type": "string"
},
"sort_by": {
"description": "SortBy sets the sort order of the result",
"type": "string"
},
"uuids": {
"description": "List of snapshot UUIDs to search",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"rpm_names",
"uuids"
],
"type": "object"
},
"api.SearchPackageGroupResponse": {
"properties": {
"description": {
Expand Down Expand Up @@ -1131,6 +1100,37 @@
},
"type": "object"
},
"api.SearchSnapshotModuleStreamsRequest": {
"properties": {
"rpm_names": {
"description": "List of rpm names to search",
"items": {
"type": "string"
},
"type": "array"
},
"search": {
"description": "Search string to search rpm names",
"type": "string"
},
"sort_by": {
"description": "SortBy sets the sort order of the result",
"type": "string"
},
"uuids": {
"description": "List of snapshot UUIDs to search",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"rpm_names",
"uuids"
],
"type": "object"
},
"api.SnapshotCollectionResponse": {
"properties": {
"data": {
Expand Down Expand Up @@ -4776,7 +4776,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/api.SearchModuleStreamsRequest"
"$ref": "#/components/schemas/api.SearchSnapshotModuleStreamsRequest"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/module_streams.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api

type SearchModuleStreamsRequest struct {
type SearchSnapshotModuleStreamsRequest struct {
UUIDs []string `json:"uuids" validate:"required"` // List of snapshot UUIDs to search
RpmNames []string `json:"rpm_names" validate:"required"` // List of rpm names to search
SortBy string `json:"sort_by"` // SortBy sets the sort order of the result
Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type RepositoryConfigDao interface {
}

type ModuleStreamsDao interface {
SearchSnapshotModuleStreams(ctx context.Context, orgID string, request api.SearchModuleStreamsRequest) (api.SearchModuleStreamsCollectionResponse, error)
SearchSnapshotModuleStreams(ctx context.Context, orgID string, request api.SearchSnapshotModuleStreamsRequest) (api.SearchModuleStreamsCollectionResponse, error)
}

type RpmDao interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/module_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetModuleStreamsDao(db *gorm.DB) ModuleStreamsDao {
}
}

func (r *moduleStreamsImpl) SearchSnapshotModuleStreams(ctx context.Context, orgID string, request api.SearchModuleStreamsRequest) (api.SearchModuleStreamsCollectionResponse, error) {
func (r *moduleStreamsImpl) SearchSnapshotModuleStreams(ctx context.Context, orgID string, request api.SearchSnapshotModuleStreamsRequest) (api.SearchModuleStreamsCollectionResponse, error) {
if orgID == "" {
return api.SearchModuleStreamsCollectionResponse{}, fmt.Errorf("orgID can not be an empty string")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/dao/module_streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *RpmSuite) TestSearchModulesForSnapshots() {
//ctx context.Context, hrefs []string, rpmNames []string, search string, pageOpts PageOption
dao := GetModuleStreamsDao(s.tx)

resp, err := dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchModuleStreamsRequest{
resp, err := dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchSnapshotModuleStreamsRequest{
UUIDs: []string{snaps[0].UUID},
RpmNames: []string(nil),
Search: "Foo",
Expand All @@ -95,15 +95,15 @@ func (s *RpmSuite) TestSearchModulesForSnapshots() {
)

// ensure error returned for invalid snapshot uuid
_, err = dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchModuleStreamsRequest{
_, err = dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchSnapshotModuleStreamsRequest{
UUIDs: []string{"blerg!"},
Search: "Foo",
})

assert.Error(s.T(), err)

// ensure error returned for no uuids
_, err = dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchModuleStreamsRequest{
_, err = dao.SearchSnapshotModuleStreams(ctx, orgId, api.SearchSnapshotModuleStreamsRequest{
UUIDs: []string{},
RpmNames: []string{},
Search: "Foo",
Expand Down
8 changes: 4 additions & 4 deletions pkg/dao/modules_streams_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/handler/module_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func RegisterModuleStreamsRoutes(engine *echo.Group, rDao *dao.DaoRegistry) {
// @Summary List modules and their streams for snapshots
// @ID searchSnapshotModuleStreams
// @Description List modules and their streams for snapshots
// @Tags snapshots
// @Tags module_streams
// @Accept json
// @Produce json
// @Param body body api.SearchModuleStreamsRequest true "request body"
// @Param body body api.SearchSnapshotModuleStreamsRequest true "request body"
// @Param uuids path []string true "Snapshot IDs."
// @Param package_names path []string true "Package Names"
// @Success 200 {object} api.SearchModuleStreamsCollectionResponse
Expand All @@ -42,7 +42,7 @@ func RegisterModuleStreamsRoutes(engine *echo.Group, rDao *dao.DaoRegistry) {
func (rh *ModuleStreamsHandler) searchSnapshotModuleStreams(c echo.Context) error {
_, orgId := getAccountIdOrgId(c)

dataInput := api.SearchModuleStreamsRequest{}
dataInput := api.SearchSnapshotModuleStreamsRequest{}

if err := c.Bind(&dataInput); err != nil {
return ce.NewErrorResponse(http.StatusBadRequest, "Error binding parameters", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/handler/module_streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (suite *ModuleStreamsSuite) TestSearchSnapshotModuleStreams() {
switch {
case testCase.Expected.Code >= 200 && testCase.Expected.Code < 300:
{
var bodyRequest api.SearchModuleStreamsRequest
var bodyRequest api.SearchSnapshotModuleStreamsRequest
err := json.Unmarshal([]byte(testCase.Given.Body), &bodyRequest)
require.NoError(t, err)
suite.dao.ModuleStreams.On("SearchSnapshotModuleStreams", mock.AnythingOfType("*context.valueCtx"), test_handler.MockOrgId, bodyRequest).
Expand Down

0 comments on commit 4294e66

Please sign in to comment.