Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Cloud
MAS
clonemap
Commits
87411bcd
Commit
87411bcd
authored
Feb 06, 2021
by
Stefan Dähling
Browse files
implement new endpoints
parent
30fd5a21
Pipeline
#405412
passed with stages
in 2 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pkg/ams/ams.go
View file @
87411bcd
...
...
@@ -171,6 +171,21 @@ func (ams *AMS) getMASInfo(masID int) (ret schemas.MASInfo, err error) {
return
}
// getMASByName returns IDs of all MAS with mathcing name
func
(
ams
*
AMS
)
getMASByName
(
name
string
)
(
masIDs
[]
int
,
err
error
)
{
var
mass
schemas
.
MASs
mass
,
err
=
ams
.
stor
.
getMASs
()
if
err
!=
nil
{
return
}
for
i
:=
range
mass
.
Inst
{
if
mass
.
Inst
[
i
]
.
Config
.
Name
==
name
{
masIDs
=
append
(
masIDs
,
i
)
}
}
return
}
// getAgents returns specs of all agents in MAS
func
(
ams
*
AMS
)
getAgents
(
masID
int
)
(
ret
schemas
.
Agents
,
err
error
)
{
ret
,
err
=
ams
.
stor
.
getAgents
(
masID
)
...
...
@@ -214,6 +229,17 @@ func (ams *AMS) updateAgentCustom(masID int, agentID int, custom string) (err er
return
}
// getAgentsByName returns IDs of all agents with matching name
func
(
ams
*
AMS
)
getAgentsByName
(
masID
int
,
name
string
)
(
agentIDs
[]
int
,
err
error
)
{
var
agents
schemas
.
Agents
for
i
:=
range
agents
.
Inst
{
if
agents
.
Inst
[
i
]
.
Spec
.
Name
==
name
{
agentIDs
=
append
(
agentIDs
,
i
)
}
}
return
}
// getAgencies returns specs of all agencies in MAS
func
(
ams
*
AMS
)
getAgencies
(
masID
int
)
(
ret
schemas
.
Agencies
,
err
error
)
{
ret
,
err
=
ams
.
stor
.
getAgencies
(
masID
)
...
...
pkg/ams/handler.go
View file @
87411bcd
...
...
@@ -262,7 +262,9 @@ func (ams *AMS) handleMASName(name string, w http.ResponseWriter, r *http.Reques
httpErr
error
)
{
if
r
.
Method
==
"GET"
{
// search for MAS with matching name
// ToDo
var
ids
[]
int
ids
,
cmapErr
=
ams
.
getMASByName
(
name
)
httpErr
=
httpreply
.
Resource
(
w
,
ids
,
cmapErr
)
}
else
{
httpErr
=
httpreply
.
MethodNotAllowed
(
w
)
cmapErr
=
errors
.
New
(
"Error: Method not allowed on path /api/clonemap/name/{name}"
)
...
...
@@ -383,7 +385,9 @@ func (ams *AMS) handleAgentName(masID int, name string, w http.ResponseWriter,
r
*
http
.
Request
)
(
cmapErr
,
httpErr
error
)
{
if
r
.
Method
==
"GET"
{
// search for agents with matching name
// ToDo
var
ids
[]
int
ids
,
cmapErr
=
ams
.
getAgentsByName
(
masID
,
name
)
httpErr
=
httpreply
.
Resource
(
w
,
ids
,
cmapErr
)
}
else
{
httpErr
=
httpreply
.
MethodNotAllowed
(
w
)
cmapErr
=
errors
.
New
(
"Error: Method not allowed on path /api/clonemap/mas/{masid}/agents/"
+
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment