From e70d3bab7b6ddf0eaa8f20e7dfd3c14abd587fd3 Mon Sep 17 00:00:00 2001 From: Albin Antony Date: Tue, 24 Oct 2023 10:50:04 +0530 Subject: [PATCH] Add #207 align audit apis --- src/config/constants.go | 1 + .../dataagreement_record.go | 24 ++ src/v2/dataagreement_record/db.go | 240 ++++++++++++++++++ .../audit/audit_list_dataagreement_records.go | 157 ++++++++++++ .../audit/audit_list_dataagreements.go | 64 +++++ .../handler/audit/audit_read_dataagreement.go | 46 ++++ .../audit/audit_read_dataagreement_record.go | 45 ++++ .../audit/auditagreementlist_handler.go | 14 - .../audit/auditconsentrecordlist_handler.go | 14 - .../audit/auditconsentrecordread_handler.go | 14 - .../handler/audit/auditreadrecord_handler.go | 14 - src/v2/http_path/audit_paths.go | 8 +- src/v2/http_path/routes.go | 8 +- 13 files changed, 585 insertions(+), 64 deletions(-) create mode 100644 src/v2/handler/audit/audit_list_dataagreement_records.go create mode 100644 src/v2/handler/audit/audit_list_dataagreements.go create mode 100644 src/v2/handler/audit/audit_read_dataagreement.go create mode 100644 src/v2/handler/audit/audit_read_dataagreement_record.go delete mode 100644 src/v2/handler/audit/auditagreementlist_handler.go delete mode 100644 src/v2/handler/audit/auditconsentrecordlist_handler.go delete mode 100644 src/v2/handler/audit/auditconsentrecordread_handler.go delete mode 100644 src/v2/handler/audit/auditreadrecord_handler.go diff --git a/src/config/constants.go b/src/config/constants.go index 1f59a15..78ab265 100644 --- a/src/config/constants.go +++ b/src/config/constants.go @@ -29,6 +29,7 @@ const ( ApiKeyId = "apiKeyId" IndividualHeaderKey = "X-ConsentBB-IndividualId" RevisionId = "revisionId" + LawfulBasis = "lawfulBasis" ) // Schemas diff --git a/src/v2/dataagreement_record/dataagreement_record.go b/src/v2/dataagreement_record/dataagreement_record.go index 94af708..1fbf1a3 100644 --- a/src/v2/dataagreement_record/dataagreement_record.go +++ b/src/v2/dataagreement_record/dataagreement_record.go @@ -28,6 +28,24 @@ type DataAttributeForDataAgreementRecord struct { OptIn bool `json:"optIn"` } +type DataAgreementForListDataAgreementRecord struct { + Id string `json:"id" bson:"_id,omitempty"` + Purpose string `json:"purpose"` +} + +type DataAgreementRecordForAuditList struct { + Id primitive.ObjectID `json:"id" bson:"_id,omitempty"` + DataAgreementId string `json:"dataAgreementId"` + DataAgreementRevisionId string `json:"dataAgreementRevisionId"` + DataAgreementRevisionHash string `json:"dataAgreementRevisionHash"` + DataAttributes []DataAttributeForDataAgreementRecord `json:"dataAttributes"` + IndividualId string `json:"individualId"` + OptIn bool `json:"optIn"` + State string `json:"state" valid:"required"` + SignatureId string `json:"signatureId"` + AgreementData []DataAgreementForListDataAgreementRecord `json:"dataAgreement"` +} + // DataAgreementRecordError is an error enumeration for create consent record API. type DataAgreementRecordError int @@ -36,6 +54,8 @@ const ( IndividualIdIsMissingError DataAgreementRecordError = iota DataAgreementIdIsMissingError RevisionIdIsMissingError + DataAgreementRecordIdIsMissingError + LawfulBasisIsMissingError ) // Error returns the string representation of the error. @@ -47,6 +67,10 @@ func (e DataAgreementRecordError) Error() string { return "Query param dataAgreementId is missing!" case RevisionIdIsMissingError: return "Query param revisionId is missing!" + case DataAgreementRecordIdIsMissingError: + return "Query param dataAgreementRecordId is missing!" + case LawfulBasisIsMissingError: + return "Query param lawfulbasis is missing!" default: return "Unknown error!" } diff --git a/src/v2/dataagreement_record/db.go b/src/v2/dataagreement_record/db.go index 73638ea..62f4426 100644 --- a/src/v2/dataagreement_record/db.go +++ b/src/v2/dataagreement_record/db.go @@ -89,3 +89,243 @@ func (darRepo *DataAgreementRecordRepository) DeleteAllRecordsForIndividual(indi return err } + +// ListByIdIncludingDataAgreement lists data agreement record by id +func ListByIdIncludingDataAgreement(dataAgreementRecordID string, organisationId string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + dataAgreementRecordId, err := primitive.ObjectIDFromHex(dataAgreementRecordID) + if err != nil { + return results, err + } + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "_id": dataAgreementRecordId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} + +// ListByIdAndLawfulBasis lists data attributes based on data agreement record and lawfulbasis +func ListByIdAndLawfulBasis(dataAgreementRecordID string, organisationId string, lawfulBasis string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + dataAgreementRecordId, err := primitive.ObjectIDFromHex(dataAgreementRecordID) + if err != nil { + return results, err + } + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "_id": dataAgreementRecordId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + { + "$match": bson.M{ + "agreementData": bson.M{ + "$elemMatch": bson.M{ + "lawfulbasis": lawfulBasis, + }, + }, + }, + }, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} + +// ListByDataAgreementIdIncludingDataAgreement lists data agreement record based on data agreement id +func ListByDataAgreementIdIncludingDataAgreement(dataAgreementId string, organisationId string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "dataagreementid": dataAgreementId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} + +// ListByDataAgreementIdAndLawfulBasis lists data agreement record based on data agreement id and lawful basis +func ListByDataAgreementIdAndLawfulBasis(dataAgreementId string, organisationId string, lawfulBasis string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "dataagreementid": dataAgreementId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + { + "$match": bson.M{ + "agreementData": bson.M{ + "$elemMatch": bson.M{ + "lawfulbasis": lawfulBasis, + }, + }, + }, + }, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} + +// ListByIndividualIdIncludingDataAgreement +func ListByIndividualIdIncludingDataAgreement(individualId string, organisationId string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "individualid": individualId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} + +func ListByIndividualIdAndLawfulBasis(individualId string, organisationId string, lawfulBasis string) ([]DataAgreementRecordForAuditList, error) { + var results []DataAgreementRecordForAuditList + + pipeline := []bson.M{ + {"$match": bson.M{"organisationid": organisationId, "isdeleted": false, "individualid": individualId}}, + {"$lookup": bson.M{ + "from": "dataAgreements", + "let": bson.M{"localId": "$dataagreementid"}, + "pipeline": bson.A{ + bson.M{ + "$match": bson.M{ + "$expr": bson.M{ + "$eq": []interface{}{"$_id", bson.M{"$toObjectId": "$$localId"}}, + }, + }, + }, + }, + "as": "agreementData", + }}, + { + "$match": bson.M{ + "agreementData": bson.M{ + "$elemMatch": bson.M{ + "lawfulbasis": lawfulBasis, + }, + }, + }, + }, + } + + cursor, err := Collection().Aggregate(context.TODO(), pipeline) + if err != nil { + return results, err + } + defer cursor.Close(context.TODO()) + + if err = cursor.All(context.TODO(), &results); err != nil { + return results, err + } + return results, nil +} diff --git a/src/v2/handler/audit/audit_list_dataagreement_records.go b/src/v2/handler/audit/audit_list_dataagreement_records.go new file mode 100644 index 0000000..3502f9e --- /dev/null +++ b/src/v2/handler/audit/audit_list_dataagreement_records.go @@ -0,0 +1,157 @@ +package audit + +import ( + "encoding/json" + "errors" + "log" + "net/http" + + "github.com/bb-consent/api/src/common" + "github.com/bb-consent/api/src/config" + daRecord "github.com/bb-consent/api/src/v2/dataagreement_record" + "github.com/bb-consent/api/src/v2/paginate" +) + +func dataAgreementRecordToInterfaceSlice(dataAgreementRecords []daRecord.DataAgreementRecordForAuditList) []interface{} { + interfaceSlice := make([]interface{}, len(dataAgreementRecords)) + for i, r := range dataAgreementRecords { + interfaceSlice[i] = r + } + return interfaceSlice +} + +type DataAgreementForListDataAgreementRecord struct { + Id string `json:"id" bson:"_id,omitempty"` + Purpose string `json:"purpose"` +} + +type fetchDataAgreementRecordsResp struct { + DataAgreementRecords interface{} `json:"dataAgreementRecords"` + Pagination paginate.Pagination `json:"pagination"` +} + +// AuditListDataAgreementRecords +func AuditListDataAgreementRecords(w http.ResponseWriter, r *http.Request) { + // Headers + organisationId := common.Sanitize(r.Header.Get(config.OrganizationId)) + + // Query params + offset, limit := paginate.ParsePaginationQueryParams(r) + log.Printf("Offset: %v and limit: %v\n", offset, limit) + + // Repository + darRepo := daRecord.DataAgreementRecordRepository{} + darRepo.Init(organisationId) + + var isNotDataAgreementRecordId bool + var isNotIndividualId bool + var isNotDataAgreementId bool + var isNotLawfulBasis bool + dataAgreementRecordId, err := daRecord.ParseQueryParams(r, config.DataAgreementRecordId, daRecord.DataAgreementRecordIdIsMissingError) + if err != nil && errors.Is(err, daRecord.DataAgreementRecordIdIsMissingError) { + isNotDataAgreementRecordId = true + } + dataAgreementId, err := daRecord.ParseQueryParams(r, config.DataAgreementId, daRecord.DataAgreementIdIsMissingError) + if err != nil && errors.Is(err, daRecord.DataAgreementIdIsMissingError) { + isNotDataAgreementId = true + } + individualId, err := daRecord.ParseQueryParams(r, config.IndividualId, daRecord.IndividualIdIsMissingError) + if err != nil && errors.Is(err, daRecord.IndividualIdIsMissingError) { + isNotIndividualId = true + } + + lawfulBasis, err := daRecord.ParseQueryParams(r, config.LawfulBasis, daRecord.LawfulBasisIsMissingError) + if err != nil && errors.Is(err, daRecord.LawfulBasisIsMissingError) { + isNotLawfulBasis = true + } + + var daRecords []daRecord.DataAgreementRecordForAuditList + if isNotLawfulBasis { + if isNotDataAgreementRecordId { + if isNotIndividualId { + if isNotDataAgreementId { + m := "Query params missing" + common.HandleErrorV2(w, http.StatusInternalServerError, m, errors.New("invalid query params")) + return + + } else { + // fetch by data agreement id + daRecords, err = daRecord.ListByDataAgreementIdIncludingDataAgreement(dataAgreementId, organisationId) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + } + + } else { + // fetch by individual id + daRecords, err = daRecord.ListByIndividualIdIncludingDataAgreement(individualId, organisationId) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + } + + } else { + // fetch by data agreement record id + daRecords, err = daRecord.ListByIdIncludingDataAgreement(dataAgreementRecordId, organisationId) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + + } + + } else { + if isNotDataAgreementRecordId { + if isNotIndividualId { + // fetch by data agreement id and lawful basis + daRecords, err = daRecord.ListByDataAgreementIdAndLawfulBasis(dataAgreementId, organisationId, lawfulBasis) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + } else { + // fetch by individual id and lawfulusage + daRecords, err = daRecord.ListByIndividualIdAndLawfulBasis(individualId, organisationId, lawfulBasis) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + } + + } else { + // fetch by data agreement record id and lawful basis + daRecords, err = daRecord.ListByIdAndLawfulBasis(dataAgreementRecordId, organisationId, lawfulBasis) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + + } + + } + query := paginate.PaginateObjectsQuery{ + Limit: limit, + Offset: offset, + } + interfaceSlice := dataAgreementRecordToInterfaceSlice(daRecords) + result := paginate.PaginateObjects(query, interfaceSlice) + + var resp = fetchDataAgreementRecordsResp{ + DataAgreementRecords: result.Items, + Pagination: result.Pagination, + } + + response, _ := json.Marshal(resp) + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + w.Write(response) + +} diff --git a/src/v2/handler/audit/audit_list_dataagreements.go b/src/v2/handler/audit/audit_list_dataagreements.go new file mode 100644 index 0000000..786ac7c --- /dev/null +++ b/src/v2/handler/audit/audit_list_dataagreements.go @@ -0,0 +1,64 @@ +package audit + +import ( + "context" + "errors" + "log" + "net/http" + + "github.com/bb-consent/api/src/common" + "github.com/bb-consent/api/src/config" + "github.com/bb-consent/api/src/v2/dataagreement" + "github.com/bb-consent/api/src/v2/paginate" +) + +type listDataAgreementsResp struct { + DataAgreements interface{} `json:"dataAgreements"` + Pagination paginate.Pagination `json:"pagination"` +} + +// AuditListDataAgreements +func AuditListDataAgreements(w http.ResponseWriter, r *http.Request) { + // Headers + organisationId := common.Sanitize(r.Header.Get(config.OrganizationId)) + + // Query params + offset, limit := paginate.ParsePaginationQueryParams(r) + log.Printf("Offset: %v and limit: %v\n", offset, limit) + + darepo := dataagreement.DataAgreementRepository{} + darepo.Init(organisationId) + + var resp listDataAgreementsResp + + // Return all data agreements + var dataAgreements []dataagreement.DataAgreement + query := paginate.PaginateDBObjectsQuery{ + Filter: darepo.DefaultFilter, + Collection: dataagreement.Collection(), + Context: context.Background(), + Limit: limit, + Offset: offset, + } + result, err := paginate.PaginateDBObjects(query, &dataAgreements) + if err != nil { + if errors.Is(err, paginate.EmptyDBError) { + emptyDataAgreements := make([]interface{}, 0) + resp = listDataAgreementsResp{ + DataAgreements: emptyDataAgreements, + Pagination: result.Pagination, + } + common.ReturnHTTPResponse(resp, w) + return + } + m := "Failed to paginate data agreement" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + + } + resp = listDataAgreementsResp{ + DataAgreements: result.Items, + Pagination: result.Pagination, + } + common.ReturnHTTPResponse(resp, w) +} diff --git a/src/v2/handler/audit/audit_read_dataagreement.go b/src/v2/handler/audit/audit_read_dataagreement.go new file mode 100644 index 0000000..d98d235 --- /dev/null +++ b/src/v2/handler/audit/audit_read_dataagreement.go @@ -0,0 +1,46 @@ +package audit + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/bb-consent/api/src/common" + "github.com/bb-consent/api/src/config" + "github.com/bb-consent/api/src/v2/dataagreement" + "github.com/gorilla/mux" +) + +type getDataAgreementResp struct { + DataAgreement dataagreement.DataAgreement `json:"dataAgreement"` +} + +// AuditReadDataAgreement +func AuditReadDataAgreement(w http.ResponseWriter, r *http.Request) { + // Headers + organisationId := common.Sanitize(r.Header.Get(config.OrganizationId)) + + dataAgreementId := common.Sanitize(mux.Vars(r)[config.DataAgreementId]) + + // Repository + daRepo := dataagreement.DataAgreementRepository{} + daRepo.Init(organisationId) + + // Fetch data agreement from db + da, err := daRepo.Get(dataAgreementId) + if err != nil { + m := fmt.Sprintf("Failed to fetch data agreement: %v", dataAgreementId) + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + + // creating response + resp := getDataAgreementResp{ + DataAgreement: da, + } + + response, _ := json.Marshal(resp) + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + w.Write(response) +} diff --git a/src/v2/handler/audit/audit_read_dataagreement_record.go b/src/v2/handler/audit/audit_read_dataagreement_record.go new file mode 100644 index 0000000..06835c9 --- /dev/null +++ b/src/v2/handler/audit/audit_read_dataagreement_record.go @@ -0,0 +1,45 @@ +package audit + +import ( + "encoding/json" + "net/http" + + "github.com/bb-consent/api/src/common" + "github.com/bb-consent/api/src/config" + daRecord "github.com/bb-consent/api/src/v2/dataagreement_record" + "github.com/gorilla/mux" +) + +type readDataAgreementRecordResp struct { + DataAgreementRecord daRecord.DataAgreementRecord `json:"dataAgreementRecord"` +} + +// AuditDataAgreementRecordRead +func AuditDataAgreementRecordRead(w http.ResponseWriter, r *http.Request) { + // Headers + organisationId := common.Sanitize(r.Header.Get(config.OrganizationId)) + + dataAgreementRecordId := common.Sanitize(mux.Vars(r)[config.DataAgreementRecordId]) + + // Repository + darRepo := daRecord.DataAgreementRecordRepository{} + darRepo.Init(organisationId) + + // fetch data agreement record from db + daRecord, err := darRepo.Get(dataAgreementRecordId) + if err != nil { + m := "Failed to fetch data agreement record" + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + + // creating response + resp := readDataAgreementRecordResp{ + DataAgreementRecord: daRecord, + } + + response, _ := json.Marshal(resp) + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + w.Write(response) +} diff --git a/src/v2/handler/audit/auditagreementlist_handler.go b/src/v2/handler/audit/auditagreementlist_handler.go deleted file mode 100644 index 23feda5..0000000 --- a/src/v2/handler/audit/auditagreementlist_handler.go +++ /dev/null @@ -1,14 +0,0 @@ -package audit - -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) - -} diff --git a/src/v2/handler/audit/auditconsentrecordlist_handler.go b/src/v2/handler/audit/auditconsentrecordlist_handler.go deleted file mode 100644 index cbbb5ea..0000000 --- a/src/v2/handler/audit/auditconsentrecordlist_handler.go +++ /dev/null @@ -1,14 +0,0 @@ -package audit - -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) - -} diff --git a/src/v2/handler/audit/auditconsentrecordread_handler.go b/src/v2/handler/audit/auditconsentrecordread_handler.go deleted file mode 100644 index 9066b37..0000000 --- a/src/v2/handler/audit/auditconsentrecordread_handler.go +++ /dev/null @@ -1,14 +0,0 @@ -package audit - -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) - -} diff --git a/src/v2/handler/audit/auditreadrecord_handler.go b/src/v2/handler/audit/auditreadrecord_handler.go deleted file mode 100644 index 443dedc..0000000 --- a/src/v2/handler/audit/auditreadrecord_handler.go +++ /dev/null @@ -1,14 +0,0 @@ -package audit - -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) - -} diff --git a/src/v2/http_path/audit_paths.go b/src/v2/http_path/audit_paths.go index 708667c..986da73 100644 --- a/src/v2/http_path/audit_paths.go +++ b/src/v2/http_path/audit_paths.go @@ -1,9 +1,9 @@ package http_path -const AuditConsentRecordList = "/v2/audit/consentrecords/" -const AuditConsentRecordRead = "/v2/audit/consentrecord/{consentRecordId}/" -const AuditAgreementList = "/v2/audit/agreements/" -const AuditReadRecord = "/v2/audit/agreement/{agreementId}/" +const AuditListDataAgreementRecords = "/v2/audit/data-agreement-records" +const AuditDataAgreementRecordRead = "/v2/audit/data-agreement-record/{dataAgreementRecordId}" +const AuditListDataAgreements = "/v2/audit/data-agreements" +const AuditReadDataAgreement = "/v2/audit/data-agreement/{dataAgreementId}" // organization action logs const AuditGetOrgLogs = "/v2/audit/admin/logs" diff --git a/src/v2/http_path/routes.go b/src/v2/http_path/routes.go index fdf8953..9e60486 100644 --- a/src/v2/http_path/routes.go +++ b/src/v2/http_path/routes.go @@ -115,10 +115,10 @@ func SetRoutes(r *mux.Router, e *casbin.Enforcer) { // Audit api(s) - r.Handle(AuditConsentRecordList, m.Chain(auditHandler.AuditConsentRecordList, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") - r.Handle(AuditConsentRecordRead, m.Chain(auditHandler.AuditConsentRecordRead, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") - r.Handle(AuditAgreementList, m.Chain(auditHandler.AuditAgreementList, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") - r.Handle(AuditReadRecord, m.Chain(auditHandler.AuditReadRecord, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") + r.Handle(AuditListDataAgreementRecords, m.Chain(auditHandler.AuditListDataAgreementRecords, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") + r.Handle(AuditDataAgreementRecordRead, m.Chain(auditHandler.AuditDataAgreementRecordRead, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") + r.Handle(AuditListDataAgreements, m.Chain(auditHandler.AuditListDataAgreements, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") + r.Handle(AuditReadDataAgreement, m.Chain(auditHandler.AuditReadDataAgreement, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET") // organization action logs r.Handle(AuditGetOrgLogs, m.Chain(auditHandler.AuditGetOrgLogs, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate(), m.AddContentType())).Methods("GET")