API: List ARNs (#19)

* API: List ARNs

* Add Tests
This commit is contained in:
Daniel Valdivia
2020-04-03 14:27:47 -07:00
committed by GitHub
parent 9c43c8894a
commit da2e9e8896
12 changed files with 685 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ package restapi
import (
"context"
"log"
"time"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
@@ -28,7 +29,7 @@ import (
)
func registerAdminInfoHandlers(api *operations.McsAPI) {
// session check
// return usage stats
api.AdminAPIAdminInfoHandler = admin_api.AdminInfoHandlerFunc(func(params admin_api.AdminInfoParams, principal *models.Principal) middleware.Responder {
infoResp, err := getAdminInfoResponse()
if err != nil {
@@ -71,7 +72,7 @@ func getAdminInfoResponse() (*models.AdminInfoResponse, error) {
// defining the client to be used
adminClient := adminClient{client: mAdmin}
// 20 seconds timeout
ctx, cancel := context.WithTimeout(context.Background(), 20)
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
// serialize output
usage, err := getAdminInfo(ctx, adminClient)