Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMS-4932: Add search module streams #897

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ packages:
TemplateDao:
config:
filename: "templates_mock.go"
ModuleStreamsDao:
config:
filename: "modules_streams_mock.go"
148 changes: 148 additions & 0 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,68 @@ const docTemplate = `{
}
}
},
"/snapshots/module_streams/search": {
"post": {
"description": "List modules and their streams for snapshots",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"module_streams"
],
"summary": "List modules and their streams for snapshots",
"operationId": "searchSnapshotModuleStreams",
"parameters": [
{
"description": "request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api.SearchSnapshotModuleStreamsRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/api.SearchModuleStreams"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/errors.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/errors.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/errors.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/errors.ErrorResponse"
}
}
}
}
},
"/snapshots/package_groups/names": {
"post": {
"description": "This enables users to search for package groups in a given list of snapshots.",
Expand Down Expand Up @@ -4582,6 +4644,22 @@ const docTemplate = `{
}
}
},
"api.SearchModuleStreams": {
"type": "object",
"properties": {
"module_name": {
"description": "Module name",
"type": "string"
},
"streams": {
"description": "A list of stream related information for the module",
"type": "array",
"items": {
"$ref": "#/definitions/api.Stream"
}
}
}
},
"api.SearchPackageGroupResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -4619,6 +4697,37 @@ const docTemplate = `{
}
}
},
"api.SearchSnapshotModuleStreamsRequest": {
"type": "object",
"required": [
"rpm_names",
"uuids"
],
"properties": {
"rpm_names": {
"description": "List of rpm names to restrict returned modules",
"type": "array",
"items": {
"type": "string"
}
},
"search": {
"description": "Search string to search module 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 Expand Up @@ -4845,6 +4954,45 @@ const docTemplate = `{
}
}
},
"api.Stream": {
"type": "object",
"properties": {
"arch": {
"description": "The Architecture of the rpm",
"type": "string"
},
"context": {
"description": "Context of the module",
"type": "string"
},
"description": {
"description": "Module description",
"type": "string"
},
"name": {
"description": "Name of the module",
"type": "string"
},
"profiles": {
"description": "Module profile data",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"stream": {
"description": "Module stream version",
"type": "string"
},
"version": {
"description": "The version of the rpm",
"type": "string"
}
}
},
"api.TaskInfoCollectionResponse": {
"type": "object",
"properties": {
Expand Down
163 changes: 163 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,22 @@
},
"type": "object"
},
"api.SearchModuleStreams": {
"properties": {
"module_name": {
"description": "Module name",
"type": "string"
},
"streams": {
"description": "A list of stream related information for the module",
"items": {
"$ref": "#/components/schemas/api.Stream"
},
"type": "array"
}
},
"type": "object"
},
"api.SearchPackageGroupResponse": {
"properties": {
"description": {
Expand Down Expand Up @@ -1076,6 +1092,37 @@
},
"type": "object"
},
"api.SearchSnapshotModuleStreamsRequest": {
"properties": {
"rpm_names": {
"description": "List of rpm names to restrict returned modules",
"items": {
"type": "string"
},
"type": "array"
},
"search": {
"description": "Search string to search module 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 @@ -1295,6 +1342,45 @@
},
"type": "object"
},
"api.Stream": {
"properties": {
"arch": {
"description": "The Architecture of the rpm",
"type": "string"
},
"context": {
"description": "Context of the module",
"type": "string"
},
"description": {
"description": "Module description",
"type": "string"
},
"name": {
"description": "Name of the module",
"type": "string"
},
"profiles": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "Module profile data",
"type": "object"
},
"stream": {
"description": "Module stream version",
"type": "string"
},
"version": {
"description": "The version of the rpm",
"type": "string"
}
},
"type": "object"
},
"api.TaskInfoCollectionResponse": {
"properties": {
"data": {
Expand Down Expand Up @@ -4667,6 +4753,83 @@
]
}
},
"/snapshots/module_streams/search": {
"post": {
"description": "List modules and their streams for snapshots",
"operationId": "searchSnapshotModuleStreams",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/api.SearchSnapshotModuleStreamsRequest"
}
}
},
"description": "request body",
"required": true,
"x-originalParamName": "body"
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/api.SearchModuleStreams"
},
"type": "array"
}
}
},
"description": "OK"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/errors.ErrorResponse"
}
}
},
"description": "Bad Request"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/errors.ErrorResponse"
}
}
},
"description": "Unauthorized"
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/errors.ErrorResponse"
}
}
},
"description": "Not Found"
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/errors.ErrorResponse"
}
}
},
"description": "Internal Server Error"
}
},
"summary": "List modules and their streams for snapshots",
"tags": [
"module_streams"
]
}
},
"/snapshots/package_groups/names": {
"post": {
"description": "This enables users to search for package groups in a given list of snapshots.",
Expand Down
23 changes: 23 additions & 0 deletions pkg/api/module_streams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package api

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 restrict returned modules
SortBy string `json:"sort_by"` // SortBy sets the sort order of the result
Search string `json:"search"` // Search string to search module names
}

type Stream struct {
Name string `json:"name"` // Name of the module
Stream string `json:"stream"` // Module stream version
Context string `json:"context"` // Context of the module
Arch string `json:"arch"` // The Architecture of the rpm
Version string `json:"version"` // The version of the rpm
Description string `json:"description"` // Module description
Profiles map[string][]string `json:"profiles"` // Module profile data
}

type SearchModuleStreams struct {
ModuleName string `json:"module_name"` // Module name
Streams []Stream `json:"streams"` // A list of stream related information for the module
}
Loading
Loading