Added compose module ID to module mapping endpoint

This commit is contained in:
Peter Grlica
2021-03-04 14:30:52 +01:00
parent 28bb344b69
commit c2d3151c2d
3 changed files with 53 additions and 5 deletions
+6 -1
View File
@@ -299,6 +299,11 @@ endpoints:
name: moduleID
required: true
title: Module ID
get:
- name: composeModuleID
type: uint64
required: false
title: Compose module id
- name: listAll
method: GET
title: List of shared/exposed/mapped modules
@@ -321,7 +326,7 @@ endpoints:
- name: mapped
type: bool
required: false
title: List exposed modules
title: List mapped modules
- title: Sync structure
description: Sync structure
+21 -1
View File
@@ -109,8 +109,28 @@ func (ctrl ManageStructure) CreateMappings(ctx context.Context, r *request.Manag
return service.DefaultModuleMapping.Create(ctx, mm)
}
// ReadMappings outputs an object with the module mappings per each federation module
func (ctrl ManageStructure) ReadMappings(ctx context.Context, r *request.ManageStructureReadMappings) (interface{}, error) {
return (service.DefaultModuleMapping).FindByID(ctx, r.ModuleID)
f := types.ModuleMappingFilter{
NodeID: r.NodeID,
FederationModuleID: r.ModuleID,
}
if r.ComposeModuleID > 0 {
f.ComposeModuleID = r.ComposeModuleID
}
set, _, err := service.DefaultModuleMapping.Find(ctx, f)
if err != nil {
return nil, err
}
if len(set) != 1 {
return nil, service.ModuleMappingErrNotFound()
}
return set[0], nil
}
// ListAll show the list of exposed / shared / mapped modules
+26 -3
View File
@@ -172,6 +172,11 @@ type (
//
// Module ID
ModuleID uint64 `json:",string"`
// ComposeModuleID GET parameter
//
// Compose module id
ComposeModuleID uint64 `json:",string"`
}
ManageStructureListAll struct {
@@ -192,7 +197,7 @@ type (
// Mapped GET parameter
//
// List exposed modules
// List mapped modules
Mapped bool
}
)
@@ -728,8 +733,9 @@ func NewManageStructureReadMappings() *ManageStructureReadMappings {
// Auditable returns all auditable/loggable parameters
func (r ManageStructureReadMappings) Auditable() map[string]interface{} {
return map[string]interface{}{
"nodeID": r.NodeID,
"moduleID": r.ModuleID,
"nodeID": r.NodeID,
"moduleID": r.ModuleID,
"composeModuleID": r.ComposeModuleID,
}
}
@@ -743,6 +749,11 @@ func (r ManageStructureReadMappings) GetModuleID() uint64 {
return r.ModuleID
}
// Auditable returns all auditable/loggable parameters
func (r ManageStructureReadMappings) GetComposeModuleID() uint64 {
return r.ComposeModuleID
}
// Fill processes request and fills internal variables
func (r *ManageStructureReadMappings) Fill(req *http.Request) (err error) {
if strings.ToLower(req.Header.Get("content-type")) == "application/json" {
@@ -756,6 +767,18 @@ func (r *ManageStructureReadMappings) Fill(req *http.Request) (err error) {
}
}
{
// GET params
tmp := req.URL.Query()
if val, ok := tmp["composeModuleID"]; ok && len(val) > 0 {
r.ComposeModuleID, err = payload.ParseUint64(val[0]), nil
if err != nil {
return err
}
}
}
{
var val string
// path params