From 5bc626687b0d4bfb81ecb1dd49b7b8f114ff4e1c Mon Sep 17 00:00:00 2001 From: Bas Kloosterman Date: Wed, 5 Oct 2022 13:48:18 +0200 Subject: [PATCH] Break up files, add events change to okapi --- okap.proto | 177 -------------------------------- okap-errors.proto => okapi-errors.proto | 16 +-- okapi-events.proto | 65 ++++++++++++ okapi-onboarding.proto | 51 +++++++++ okapi-patient-registration.proto | 56 ++++++++++ okapi-service-config.proto | 74 +++++++++++++ okapi.proto | 27 +++++ 7 files changed, 282 insertions(+), 184 deletions(-) delete mode 100644 okap.proto rename okap-errors.proto => okapi-errors.proto (59%) create mode 100644 okapi-events.proto create mode 100644 okapi-onboarding.proto create mode 100644 okapi-patient-registration.proto create mode 100644 okapi-service-config.proto create mode 100644 okapi.proto diff --git a/okap.proto b/okap.proto deleted file mode 100644 index 6e7bd34..0000000 --- a/okap.proto +++ /dev/null @@ -1,177 +0,0 @@ -syntax = "proto3"; -import "okap-errors.proto"; -option go_package = "whiteboxsystems.nl/okap"; - -service OKAP { - // Onboarding - rpc GetMetadata (GetMetadataRequest) returns (GetMetadataResponse) {} - rpc Register (RegisterRequest) returns (RegisterResponse) {} - rpc CompleteRegistration (CompleteRegistrationRequest) returns (CompleteRegistrationResponse) {} - - // Configuration - rpc ConfigureCallback (ConfigureCallbackRequest) returns (ConfigureCallbackResponse) {} - rpc ListServices (ListServicesRequest) returns (ListServicesResponse) {} - - rpc UpdatePatientRegistration (UpdatePatientRegistrationRequest) returns (UpdatePatientRegistrationResponse) {} - rpc ListPatientRegistration (ListPatientRegistrationRequest) returns (ListPatientRegistrationResponse) {} -} - -enum XISAuthMethod { - mTLS = 0; - BearerToken = 1; -} - -message MTLSConfigurationParams { - string publicKey = 1; -} - -message BearerTokenConfigurationParams { - string token = 1; -} - -message XISAuthConfiguration { - XISAuthMethod method = 1; - oneof config { - MTLSConfigurationParams mtlsConfig = 2; - BearerTokenConfigurationParams apiTokenConfig = 3; - } -} - -message ProtocolAuthConfiguration { - string method = 1; - map configuration = 2; -} - -enum SubscriptionPolicy { - subnone = 0; - optin = 1; - optout = 2; -} - -enum ConsentPolicy { - consentnone = 0; - explicit = 1; - presumed = 2; -} - -message ProtocolDefinition { - string protocol = 1; - repeated string authMethods = 2; -} - -message ServiceDefinition { - string id = 1; - string name = 2; - string description = 3; - SubscriptionPolicy subscriptionPolicy = 4; - ConsentPolicy consentPolicy = 5; - repeated ProtocolDefinition fetchProtocols = 6; - repeated ProtocolDefinition pushProtocols = 7; -} - -message GetMetadataRequest {} - -message GetMetadataResponse { - string supplierFormalName = 1; - string supplierDisplayName = 2; - string productName = 3; - string version = 4; -} - -message RegisterRequest { - string organisationFormalName = 1; - string organisationDisplayName = 2; - string organisationIdentifier = 3; - string organisationIdentifierType = 4; // Type bijv. AGB, BIG registratie of KvK - XISAuthConfiguration auth = 5; -} - -message RegisterResponse { - string reference = 1; -} - -message CompleteRegistrationRequest { - string reference = 1; - string registrationToken = 2; -} - -message CompleteRegistrationResponse {} - -message CallbackConfig { - string protocol = 1; - map config = 2; - ProtocolAuthConfiguration auth = 3; -} - -message ConfigureCallbackRequest { - string serviceId = 1; - bool enabled = 2; - CallbackConfig fetch = 3; - CallbackConfig push = 4; -} - -message ConfigureCallbackResponse { - string serviceId = 1; - bool enabled = 2; - CallbackConfig fetch = 3; - CallbackConfig push = 4; -} - -message ListServicesRequest { -} - -message ServiceConfiguration { - string serviceId = 1; - bool enabled = 2; - CallbackConfig fetch = 3; - CallbackConfig push = 4; -} - -message ListServicesResponse { - repeated ServiceDefinition availableServices = 1; - repeated ServiceConfiguration configurations = 2; -} - -message PatientMeta { - string identifier = 1; - string identifierType = 2; - string firstname = 3; - string surname = 4; - string birthdate = 5; - string street = 6; - string streetNumber = 7; - string streetNumberExtension = 8; - string postalCode = 9; - string city = 10; - string country = 11; - map extra = 12; -} - -message PatientRegistrationData { - PatientMeta subject = 1; - bool registered = 2; - map callbackProtocolMeta = 3; -} - -message PatientRegistrationError { - int32 index = 1; - OKAPError error = 2; -} - -message UpdatePatientRegistrationRequest { - string serviceId = 1; - repeated PatientRegistrationData PatientRegistrationData = 2; - bool atomicUpdate = 3; -} - -message UpdatePatientRegistrationResponse { - repeated PatientRegistrationError errors = 2; -} - -message ListPatientRegistrationRequest { - string serviceId = 1; -} - -message ListPatientRegistrationResponse { - repeated PatientRegistrationData PatientRegistrationData = 2; -} diff --git a/okap-errors.proto b/okapi-errors.proto similarity index 59% rename from okap-errors.proto rename to okapi-errors.proto index c407c05..7abe7ce 100644 --- a/okap-errors.proto +++ b/okapi-errors.proto @@ -1,14 +1,14 @@ syntax = "proto3"; -option go_package = "whiteboxsystems.nl/okap"; +option go_package = "whiteboxsystems.nl/okapi"; -enum OKAPErrorCode { +enum OkAPIErrorCode { None = 0; // Invalide configuratie voor de gekozen methode InvalidXISAuthConfiguration = 1; // Onbekende reference meegegeven UnkownReference = 2; - // Invalide registratietoken voor deze reference - InvalidRegistrationToken = 3; + // Invalide autorisatietoken voor deze reference + InvalidAuthorisationToken = 3; // Onbekende service UnknownService = 4; // Onbekende protocol @@ -17,11 +17,13 @@ enum OKAPErrorCode { InvalidProcotolConfig = 6; // Authenticatie methode onbekend UnknownAuthMethod = 7; - // Invalide authorizatie configuratie voor het aangegeven protocol + // Invalide authorisatie configuratie voor het aangegeven protocol InvalidProcotolAuthConfig = 8; + // Er zijn niet genoeg events om deze pagina te bereiken + InvalidPage = 9; } -message OKAPError { - OKAPErrorCode code = 1; +message OkAPIError { + OkAPIErrorCode code = 1; string message = 2; } diff --git a/okapi-events.proto b/okapi-events.proto new file mode 100644 index 0000000..02c2629 --- /dev/null +++ b/okapi-events.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +option go_package = "whiteboxsystems.nl/okapi"; + +// idea: +// query: +// /:type[/:subtype+]/:service/:patient with wildcard + +// Should events payloads be documented by for example json schema? +message Event { + uint64 timestamp = 1; + string type = 2; + string serviceId = 3; + string patientId = 4; + google.protobuf.Struct payload = 5; + // string schema = 6; // ? do we need a schema in the event itself +} +message Query { + uint64 start = 1; + uint64 end = 2; + string type = 3; + string serviceId = 4; + string patientId = 5; +} + +message GetEventsRequest { + int32 page = 2; + int32 perPage = 3; + repeated Query query = 4; +} + +message GetEventsResponse { + int32 page = 2; + int32 perPage = 3; + repeated Event events = 4; +} + +message GetEventsStreamRequest { + repeated Query query = 2; +} + +// enum EventCallbackMethod { +// none = 0; +// webhook = 1; +// } + +// message EventCallback { +// string id = 1; // who fills this +// bool active = 2; +// EventCallbackMethod method = 3; +// repeated Query query = 4; +// } + +// message RegisterEventCallbackRequest { +// repeated EventCallback callbacks = 1; +// } + +// message RegisterEventCallbackResponse {} + +// message ListEventCallbacksRequest { +// } + +// message ListEventCallbacksResponse { +// repeated EventCallback callbacks = 1; +// } \ No newline at end of file diff --git a/okapi-onboarding.proto b/okapi-onboarding.proto new file mode 100644 index 0000000..6ea1e46 --- /dev/null +++ b/okapi-onboarding.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +option go_package = "whiteboxsystems.nl/okapi"; + +enum XISAuthMethod { + mTLS = 0; + BearerToken = 1; +} + +message MTLSConfigurationParams { + string publicKey = 1; +} + +message BearerTokenConfigurationParams { + string token = 1; +} + +message XISAuthConfiguration { + XISAuthMethod method = 1; + oneof configuration { + MTLSConfigurationParams mtlsConfiguration = 2; + BearerTokenConfigurationParams apiTokenConfiguration = 3; + } +} + +message GetMetadataRequest {} + +message GetMetadataResponse { + string supplierFormalName = 1; + string supplierDisplayName = 2; + string productName = 3; + string version = 4; +} + +message RegisterRequest { + string organisationFormalName = 1; + string organisationDisplayName = 2; + string organisationIdentifier = 3; + string organisationIdentifierType = 4; // Type bijv. AGB, BIG registratie of KvK + XISAuthConfiguration auth = 5; +} + +message RegisterResponse { + string reference = 1; +} + +message CompleteRegistrationRequest { + string reference = 1; + string authorisationToken = 2; +} + +message CompleteRegistrationResponse {} \ No newline at end of file diff --git a/okapi-patient-registration.proto b/okapi-patient-registration.proto new file mode 100644 index 0000000..3e6db98 --- /dev/null +++ b/okapi-patient-registration.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +import "okapi-errors.proto"; +option go_package = "whiteboxsystems.nl/okapi"; + +message Identifier { + string type = 1; + string value = 2; +} + +message PatientRegistrationData { + PatientMeta subject = 1; + bool registered = 2; + string id = 3; + google.protobuf.Struct callbackProtocolMeta = 4; +} + +message PatientMeta { + repeated Identifier identifier = 1; + string firstname = 2; + string surname = 3; + string surnamePrefix = 4; + string birthdate = 5; + string street = 6; + string streetNumber = 7; + string streetNumberExtension = 8; + string postalCode = 9; + string city = 10; + string country = 11; + google.protobuf.Struct extra = 12; +} + +message PatientRegistrationError { + int32 index = 1; + OkAPIError error = 2; +} + +// Probably do this steaming (also)? + +message UpdatePatientRegistrationRequest { + string serviceId = 1; + repeated PatientRegistrationData PatientRegistrationData = 2; + bool atomicUpdate = 3; +} + +message UpdatePatientRegistrationResponse { + repeated PatientRegistrationError errors = 1; +} + +message ListPatientRegistrationRequest { + string serviceId = 1; +} + +message ListPatientRegistrationResponse { + repeated PatientRegistrationData PatientRegistrationData = 1; +} \ No newline at end of file diff --git a/okapi-service-config.proto b/okapi-service-config.proto new file mode 100644 index 0000000..79666e2 --- /dev/null +++ b/okapi-service-config.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +option go_package = "whiteboxsystems.nl/okapi"; + +// ConfigureCallback + +message ProtocolAuthConfiguration { + string method = 1; + google.protobuf.Struct configuration = 2; +} + +enum SubscriptionPolicy { + subnone = 0; + optin = 1; + optout = 2; +} + +enum ConsentPolicy { + consentnone = 0; + explicit = 1; + presumed = 2; +} + +message ProtocolDefinition { + string protocol = 1; + repeated string authMethods = 2; +} + +message ServiceDefinition { + string id = 1; + string name = 2; + string description = 3; + SubscriptionPolicy subscriptionPolicy = 4; + ConsentPolicy consentPolicy = 5; + repeated ProtocolDefinition fetchProtocols = 6; + repeated ProtocolDefinition pushProtocols = 7; +} + +message CallbackConfiguration { + string protocol = 1; + google.protobuf.Struct configuration = 2; + ProtocolAuthConfiguration auth = 3; +} + +message ConfigureCallbackRequest { + string serviceId = 1; + bool enabled = 2; + CallbackConfiguration fetch = 3; + CallbackConfiguration push = 4; +} + +message ConfigureCallbackResponse { + string serviceId = 1; + bool enabled = 2; + CallbackConfiguration fetch = 3; + CallbackConfiguration push = 4; +} + +// ListServices + +message ServiceConfiguration { + string serviceId = 1; + bool enabled = 2; + CallbackConfiguration fetch = 3; + CallbackConfiguration push = 4; +} + +message ListServicesRequest { +} + +message ListServicesResponse { + repeated ServiceDefinition availableServices = 1; + repeated ServiceConfiguration configurations = 2; +} \ No newline at end of file diff --git a/okapi.proto b/okapi.proto new file mode 100644 index 0000000..8443130 --- /dev/null +++ b/okapi.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +import "okapi-onboarding.proto"; +import "okapi-service-config.proto"; +import "okapi-patient-registration.proto"; +import "okapi-events.proto"; +option go_package = "whiteboxsystems.nl/okapi"; + +service OkAPI { + // Onboarding + rpc GetMetadata (GetMetadataRequest) returns (GetMetadataResponse) {} + rpc Register (RegisterRequest) returns (RegisterResponse) {} + rpc CompleteRegistration (CompleteRegistrationRequest) returns (CompleteRegistrationResponse) {} + + // Configuration + rpc ConfigureCallback (ConfigureCallbackRequest) returns (ConfigureCallbackResponse) {} + rpc ListServices (ListServicesRequest) returns (ListServicesResponse) {} + + rpc UpdatePatientRegistration (UpdatePatientRegistrationRequest) returns (UpdatePatientRegistrationResponse) {} + rpc ListPatientRegistration (ListPatientRegistrationRequest) returns (ListPatientRegistrationResponse) {} + + // Events + rpc GetEvents (GetEventsRequest) returns (GetEventsResponse) {} + rpc GetEventsStream (GetEventsStreamRequest) returns (stream Event) {} + // rpc RegisterEventCallback (RegisterEventCallbackRequest) returns (RegisterEventCallbackResponse) {} + // rpc ListEventCallbacks (ListEventCallbacksRequest) returns (ListEventCallbacksResponse) {} +} +