-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #192 Align APIs to GovStack: Change URL paths for audit endpoints
- Loading branch information
1 parent
50f5b0f
commit ae4b7ff
Showing
8 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
Submodule config
updated
from 50757d to 3fea7a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package handlerv2 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/bb-consent/api/src/config" | ||
) | ||
|
||
func AuditAgreementList(w http.ResponseWriter, r *http.Request) { | ||
|
||
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) | ||
w.WriteHeader(http.StatusOK) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package handlerv2 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/bb-consent/api/src/config" | ||
) | ||
|
||
func AuditConsentRecordList(w http.ResponseWriter, r *http.Request) { | ||
|
||
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) | ||
w.WriteHeader(http.StatusOK) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package handlerv2 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/bb-consent/api/src/config" | ||
) | ||
|
||
func AuditConsentRecordRead(w http.ResponseWriter, r *http.Request) { | ||
|
||
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) | ||
w.WriteHeader(http.StatusOK) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package handlerv2 | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/bb-consent/api/src/config" | ||
) | ||
|
||
func AuditReadRecord(w http.ResponseWriter, r *http.Request) { | ||
|
||
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) | ||
w.WriteHeader(http.StatusOK) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package handlerv2 | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/bb-consent/api/src/actionlog" | ||
"github.com/bb-consent/api/src/common" | ||
"github.com/bb-consent/api/src/config" | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
type orgLog struct { | ||
ID string | ||
Type int | ||
TypeStr string | ||
UserID string | ||
UserName string | ||
TimeStamp string | ||
Log string | ||
} | ||
type orgLogsResp struct { | ||
Logs []orgLog | ||
Links common.PaginationLinks | ||
} | ||
|
||
// GetOrgLogs Get action logs for the organization | ||
func GetOrgLogs(w http.ResponseWriter, r *http.Request) { | ||
orgID := mux.Vars(r)["orgID"] | ||
|
||
startID, limit := common.ParsePaginationQueryParameters(r) | ||
if limit == 0 { | ||
limit = 50 | ||
} | ||
|
||
sanitizedOrgId := common.Sanitize(orgID) | ||
|
||
logs, lastID, err := actionlog.GetAccessLogByOrgID(sanitizedOrgId, startID, limit) | ||
if err != nil { | ||
m := fmt.Sprintf("Failed to get logs for organization: %v", orgID) | ||
common.HandleError(w, http.StatusInternalServerError, m, err) | ||
return | ||
} | ||
|
||
var ls orgLogsResp | ||
for _, l := range logs { | ||
ls.Logs = append(ls.Logs, orgLog{ID: l.ID.Hex(), Type: l.Type, TypeStr: l.TypeStr, | ||
UserID: l.UserID, UserName: l.UserName, TimeStamp: l.ID.Timestamp().String(), Log: l.Action}) | ||
} | ||
|
||
ls.Links = common.CreatePaginationLinks(r, startID, lastID, limit) | ||
response, _ := json.Marshal(ls) | ||
w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) | ||
w.Write(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
package httppathsv2 | ||
|
||
const AuditConsentRecordList = "/v2/audit/consentrecords/" | ||
const AuditConsentRecordRead = "/v2/audit/consentrecord/{consentRecordId}/" | ||
const AuditAgreementList = "/v2/audit/agreements/" | ||
const AuditReadRecord = "/v2/audit/agreement/{agreementId}/" | ||
|
||
// organization action logs | ||
const GetOrgLogs = "/v2/audit/admin/logs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters