From 20c80f5c0601831a742c76f11348830c45d442c4 Mon Sep 17 00:00:00 2001 From: Albin Antony Date: Wed, 4 Oct 2023 14:34:01 +0530 Subject: [PATCH] Add #191 Align APIs to GovStack: Change URL paths for service endpoints --- resources/config | 2 +- ...cecreateindividualconsentrecord_handler.go | 14 +++++++++++++ ...servicelistindividualrecordlist_handler.go | 14 +++++++++++++ ...servicereadindividualrecordread_handler.go | 14 +++++++++++++ ...ceupdateindividualconsentrecord_handler.go | 14 +++++++++++++ ...ationagreementconsentrecordread_handler.go | 14 +++++++++++++ ...erviceverificationagreementlist_handler.go | 14 +++++++++++++ ...ceverificationconsentrecordlist_handler.go | 14 +++++++++++++ src/httppathsv2/routes.go | 21 +++++++++++++++++++ src/httppathsv2/service_paths.go | 20 ++++++++++++++++++ 10 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/handlerv2/servicecreateindividualconsentrecord_handler.go create mode 100644 src/handlerv2/servicelistindividualrecordlist_handler.go create mode 100644 src/handlerv2/servicereadindividualrecordread_handler.go create mode 100644 src/handlerv2/serviceupdateindividualconsentrecord_handler.go create mode 100644 src/handlerv2/serviceverificationagreementconsentrecordread_handler.go create mode 100644 src/handlerv2/serviceverificationagreementlist_handler.go create mode 100644 src/handlerv2/serviceverificationconsentrecordlist_handler.go diff --git a/resources/config b/resources/config index 7127a97..50757de 160000 --- a/resources/config +++ b/resources/config @@ -1 +1 @@ -Subproject commit 7127a9767b3374d257e5fdfd39afef061fc954e3 +Subproject commit 50757def4650ffae1289208215ed83fe008e9ad6 diff --git a/src/handlerv2/servicecreateindividualconsentrecord_handler.go b/src/handlerv2/servicecreateindividualconsentrecord_handler.go new file mode 100644 index 0000000..64c9a13 --- /dev/null +++ b/src/handlerv2/servicecreateindividualconsentrecord_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceCreateIndividualConsentRecord(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/servicelistindividualrecordlist_handler.go b/src/handlerv2/servicelistindividualrecordlist_handler.go new file mode 100644 index 0000000..b5700a3 --- /dev/null +++ b/src/handlerv2/servicelistindividualrecordlist_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceListIndividualRecordList(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/servicereadindividualrecordread_handler.go b/src/handlerv2/servicereadindividualrecordread_handler.go new file mode 100644 index 0000000..5fbc337 --- /dev/null +++ b/src/handlerv2/servicereadindividualrecordread_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceReadIndividualRecordRead(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/serviceupdateindividualconsentrecord_handler.go b/src/handlerv2/serviceupdateindividualconsentrecord_handler.go new file mode 100644 index 0000000..8461fed --- /dev/null +++ b/src/handlerv2/serviceupdateindividualconsentrecord_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceUpdateIndividualConsentRecord(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/serviceverificationagreementconsentrecordread_handler.go b/src/handlerv2/serviceverificationagreementconsentrecordread_handler.go new file mode 100644 index 0000000..f10ff47 --- /dev/null +++ b/src/handlerv2/serviceverificationagreementconsentrecordread_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceVerificationAgreementConsentRecordRead(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/serviceverificationagreementlist_handler.go b/src/handlerv2/serviceverificationagreementlist_handler.go new file mode 100644 index 0000000..1d5c11f --- /dev/null +++ b/src/handlerv2/serviceverificationagreementlist_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceVerificationAgreementList(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/handlerv2/serviceverificationconsentrecordlist_handler.go b/src/handlerv2/serviceverificationconsentrecordlist_handler.go new file mode 100644 index 0000000..f4e0a25 --- /dev/null +++ b/src/handlerv2/serviceverificationconsentrecordlist_handler.go @@ -0,0 +1,14 @@ +package handlerv2 + +import ( + "net/http" + + "github.com/bb-consent/api/src/config" +) + +func ServiceVerificationConsentRecordList(w http.ResponseWriter, r *http.Request) { + + w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) + w.WriteHeader(http.StatusOK) + +} diff --git a/src/httppathsv2/routes.go b/src/httppathsv2/routes.go index 3e13f2c..387b5ea 100644 --- a/src/httppathsv2/routes.go +++ b/src/httppathsv2/routes.go @@ -60,4 +60,25 @@ func SetRoutes(r *mux.Router, e *casbin.Enforcer) { r.Handle(DeleteAPIKey, m.Chain(handler.DeleteAPIKey, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("DELETE") r.Handle(GetAPIKey, m.Chain(handler.GetAPIKey, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + // Service api(s) + + // Data agreements + r.Handle(ServiceDataAgreementRead, m.Chain(handler.GetDataAgreementById, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + + // Global policy configuration + r.Handle(ServicePolicyRead, m.Chain(handler.GetGlobalPolicyConfiguration, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + + // Data attributes + r.Handle(ServiceGetDataAttributes, m.Chain(handler.GetDataAttributes, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + + // Verification mechanisms + r.Handle(ServiceVerificationAgreementList, m.Chain(handler.ServiceVerificationAgreementList, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + r.Handle(ServiceVerificationAgreementConsentRecordRead, m.Chain(handler.ServiceVerificationAgreementConsentRecordRead, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + r.Handle(ServiceVerificationConsentRecordList, m.Chain(handler.ServiceVerificationConsentRecordList, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + + // Recording consent + r.Handle(ServiceCreateIndividualConsentRecord, m.Chain(handler.ServiceCreateIndividualConsentRecord, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("POST") + r.Handle(ServiceUpdateIndividualConsentRecord, m.Chain(handler.ServiceUpdateIndividualConsentRecord, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("PUT") + r.Handle(ServiceListIndividualRecordList, m.Chain(handler.ServiceListIndividualRecordList, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") + r.Handle(ServiceReadIndividualRecordRead, m.Chain(handler.ServiceReadIndividualRecordRead, m.Logger(), m.Authorize(e), m.SetApplicationMode(), m.Authenticate())).Methods("GET") } diff --git a/src/httppathsv2/service_paths.go b/src/httppathsv2/service_paths.go index 4d9bf1a..23e6f72 100644 --- a/src/httppathsv2/service_paths.go +++ b/src/httppathsv2/service_paths.go @@ -1 +1,21 @@ package httppathsv2 + +// Data agreements +const ServiceDataAgreementRead = "/v2/service/data-agreement/{dataAgreementId}/" + +// Global policy configuration +const ServicePolicyRead = "/v2/service/policy" + +// Data attributes +const ServiceGetDataAttributes = "/v2/service/data-agreements/data-attributes" + +// Verification mechanisms +const ServiceVerificationAgreementList = "/v2/service/verification/data-agreements/" +const ServiceVerificationAgreementConsentRecordRead = "/v2/service/verification/data-agreement/" +const ServiceVerificationConsentRecordList = "/v2/service/verification/records" + +// Recording consent +const ServiceCreateIndividualConsentRecord = "/v2/service/individual/data-agreement/{dataAgreementId}/record" +const ServiceUpdateIndividualConsentRecord = "/v2/service/individual/data-agreement/{dataAgreementRecordId}" +const ServiceListIndividualRecordList = "/v2/service/individual/record/data-agreement/" +const ServiceReadIndividualRecordRead = "/v2/service/individual/record/data-agreement/{dataAgreementId}/"