mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:07:02 +00:00
feature/grpc_basic_feature : refactor
This commit is contained in:
parent
f346967c2a
commit
4bb860cb85
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@ obp-api/src/main/resources/log4j.properties
|
||||
obp-api/src/main/scripts/kafka/kafka_*
|
||||
obp-api/src/main/scripts/kafka/logs/
|
||||
obp-api/src/main/scripts/kafka/tmp/
|
||||
/obp-commons/src/main/resources/git.properties
|
||||
|
||||
@ -79,6 +79,7 @@ import code.migration.MigrationScriptLog
|
||||
import code.model._
|
||||
import code.model.dataAccess._
|
||||
import code.model.dataAccess.internalMapping.AccountIdMapping
|
||||
import code.obp.grpc.HelloWorldServer
|
||||
import code.productAttributeattribute.MappedProductAttribute
|
||||
import code.productcollection.MappedProductCollection
|
||||
import code.productcollectionitem.MappedProductCollectionItem
|
||||
@ -112,7 +113,7 @@ import net.liftweb.sitemap.Loc._
|
||||
import net.liftweb.sitemap._
|
||||
import net.liftweb.util.Helpers._
|
||||
import net.liftweb.util.{Helpers, Props, Schedule, _}
|
||||
import scalapb.demo.HelloWorldServer
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
|
||||
}
|
||||
}
|
||||
|
||||
def failIfBadAuthorizationHeader(rd: Option[ResourceDoc])(fn: CallContext => Box[JsonResponse]) : JsonResponse = {
|
||||
def failIfBadAuthorizationHeader(rd: Option[ResourceDoc])(fn: CallContext => Box[JsonResponse],req: Box[Req] = S.request) : JsonResponse = {
|
||||
val authorization = S.request.map(_.header("Authorization")).flatten
|
||||
val body: Box[String] = getRequestBody(S.request)
|
||||
val implementedInVersion = S.request.openOrThrowException(attemptedToOpenAnEmptyBox).view
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
package code.management
|
||||
|
||||
import code.api.{OBPRestHelper}
|
||||
private case class PlaceHolderClassToSupressCompileWarning()
|
||||
/*
|
||||
import code.api.OBPRestHelper
|
||||
import code.api.util.APIUtil._
|
||||
import code.model._
|
||||
import net.liftweb.common.{Full, Failure}
|
||||
import net.liftweb.common.{Failure, Full}
|
||||
import net.liftweb.http.js.JE.JsRaw
|
||||
import net.liftweb.http.rest.RestHelper
|
||||
import code.util.Helper.MdcLoggable
|
||||
/*
|
||||
import com.openbankproject.commons.model.BankId
|
||||
|
||||
object AccountsAPI extends OBPRestHelper with MdcLoggable {
|
||||
//needs to be a RestHelper to get access to JsonGet, JsonPost, etc.
|
||||
self: RestHelper =>
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package code.obp.api
|
||||
package code.obp.grpc
|
||||
|
||||
import code.obp.grpc.api.{AccountsGrpc, BankIdAccountIdAndUserId, BankIdAccountIdAndUserIdGrpc, BankIdAndAccountId, BankIdGrpc, BankIdUserIdGrpc, BanksJson400Grpc, CoreTransactionsJsonV300Grpc, ObpServiceGrpc}
|
||||
import code.obp.grpc.api._
|
||||
import com.google.protobuf.empty.Empty
|
||||
import io.grpc.{ManagedChannel, ManagedChannelBuilder}
|
||||
import scalapb.demo.HelloWorldServer
|
||||
|
||||
|
||||
object Client extends App {
|
||||
private val channelBuilder = ManagedChannelBuilder.forAddress("127.0.0.1", HelloWorldServer.port)
|
||||
private val channelBuilder = ManagedChannelBuilder.forAddress("demo.openbankproject.com", HelloWorldServer.port)
|
||||
.usePlaintext()
|
||||
.asInstanceOf[ManagedChannelBuilder[_]]
|
||||
val channel: ManagedChannel = channelBuilder.build()
|
||||
@ -18,7 +16,7 @@ object Client extends App {
|
||||
println(banks)
|
||||
|
||||
// get accounts according bankId and userId
|
||||
private val bankIdUserIdGrpc = BankIdUserIdGrpc("psd201-bank-y--uk", "4850d4c3-220a-4a72-9d3c-eeeacaf4b63b")
|
||||
private val bankIdUserIdGrpc = BankIdUserIdGrpc("dmo.07.de.de", "0986f84c-78ce-4ce9-a3b7-fa2451acd882")
|
||||
private val accounts: AccountsGrpc = obpService.getPrivateAccountsAtOneBank(bankIdUserIdGrpc)
|
||||
println(accounts)
|
||||
|
||||
@ -26,4 +24,4 @@ object Client extends App {
|
||||
private val bankIdAccountIdAndUserId = BankIdAccountIdAndUserIdGrpc("psd201-bank-y--uk", "my_account_id", "4850d4c3-220a-4a72-9d3c-eeeacaf4b63b")
|
||||
private val transactionsJsonV300Grpc: CoreTransactionsJsonV300Grpc = obpService.getCoreTransactionsForBankAccount(bankIdAccountIdAndUserId)
|
||||
println(transactionsJsonV300Grpc)
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package scalapb.demo
|
||||
package code.obp.grpc
|
||||
|
||||
import java.util.logging.Logger
|
||||
|
||||
@ -93,7 +93,7 @@ class HelloWorldServer(executionContext: ExecutionContext) { self =>
|
||||
(user, _) <- NewStyle.function.findByUserId(userId, callContext)
|
||||
} yield {
|
||||
val privateViewsUserCanAccessAtOneBank = Views.views.vend.privateViewsUserCanAccess(user).filter(_.bankId == bankId)
|
||||
val availablePrivateAccounts:List[BankAccount] = bank.privateAccounts(privateViewsUserCanAccessAtOneBank)
|
||||
val availablePrivateAccounts = bank.privateAccounts(privateViewsUserCanAccessAtOneBank)
|
||||
val jValue = OBPAPI4_0_0.Implementations2_0_0.processAccounts(privateViewsUserCanAccessAtOneBank, availablePrivateAccounts)
|
||||
val jArray = JArray(
|
||||
jValue.asInstanceOf[JArray].arr.map(it => {
|
||||
@ -1,142 +0,0 @@
|
||||
// Generated by the Scala Plugin for the Protocol Buffer Compiler.
|
||||
// Do not edit!
|
||||
//
|
||||
// Protofile syntax: PROTO3
|
||||
|
||||
package code.obp.grpc.api
|
||||
|
||||
@SerialVersionUID(0L)
|
||||
final case class BankIdAccountIdAndUserId(
|
||||
bankId: _root_.scala.Predef.String = "",
|
||||
accountId: _root_.scala.Predef.String = "",
|
||||
userId: _root_.scala.Predef.String = ""
|
||||
) extends scalapb.GeneratedMessage with scalapb.Message[BankIdAccountIdAndUserId] with scalapb.lenses.Updatable[BankIdAccountIdAndUserId] {
|
||||
@transient
|
||||
private[this] var __serializedSizeCachedValue: _root_.scala.Int = 0
|
||||
private[this] def __computeSerializedValue(): _root_.scala.Int = {
|
||||
var __size = 0
|
||||
if (bankId != "") { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, bankId) }
|
||||
if (accountId != "") { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, accountId) }
|
||||
if (userId != "") { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(3, userId) }
|
||||
__size
|
||||
}
|
||||
final override def serializedSize: _root_.scala.Int = {
|
||||
var read = __serializedSizeCachedValue
|
||||
if (read == 0) {
|
||||
read = __computeSerializedValue()
|
||||
__serializedSizeCachedValue = read
|
||||
}
|
||||
read
|
||||
}
|
||||
def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
|
||||
{
|
||||
val __v = bankId
|
||||
if (__v != "") {
|
||||
_output__.writeString(1, __v)
|
||||
}
|
||||
};
|
||||
{
|
||||
val __v = accountId
|
||||
if (__v != "") {
|
||||
_output__.writeString(2, __v)
|
||||
}
|
||||
};
|
||||
{
|
||||
val __v = userId
|
||||
if (__v != "") {
|
||||
_output__.writeString(3, __v)
|
||||
}
|
||||
};
|
||||
}
|
||||
def mergeFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): code.obp.grpc.api.BankIdAccountIdAndUserId = {
|
||||
var __bankId = this.bankId
|
||||
var __accountId = this.accountId
|
||||
var __userId = this.userId
|
||||
var _done__ = false
|
||||
while (!_done__) {
|
||||
val _tag__ = _input__.readTag()
|
||||
_tag__ match {
|
||||
case 0 => _done__ = true
|
||||
case 10 =>
|
||||
__bankId = _input__.readString()
|
||||
case 18 =>
|
||||
__accountId = _input__.readString()
|
||||
case 26 =>
|
||||
__userId = _input__.readString()
|
||||
case tag => _input__.skipField(tag)
|
||||
}
|
||||
}
|
||||
code.obp.grpc.api.BankIdAccountIdAndUserId(
|
||||
bankId = __bankId,
|
||||
accountId = __accountId,
|
||||
userId = __userId
|
||||
)
|
||||
}
|
||||
def withBankId(__v: _root_.scala.Predef.String): BankIdAccountIdAndUserId = copy(bankId = __v)
|
||||
def withAccountId(__v: _root_.scala.Predef.String): BankIdAccountIdAndUserId = copy(accountId = __v)
|
||||
def withUserId(__v: _root_.scala.Predef.String): BankIdAccountIdAndUserId = copy(userId = __v)
|
||||
def getFieldByNumber(__fieldNumber: _root_.scala.Int): scala.Any = {
|
||||
(__fieldNumber: @_root_.scala.unchecked) match {
|
||||
case 1 => {
|
||||
val __t = bankId
|
||||
if (__t != "") __t else null
|
||||
}
|
||||
case 2 => {
|
||||
val __t = accountId
|
||||
if (__t != "") __t else null
|
||||
}
|
||||
case 3 => {
|
||||
val __t = userId
|
||||
if (__t != "") __t else null
|
||||
}
|
||||
}
|
||||
}
|
||||
def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
|
||||
require(__field.containingMessage eq companion.scalaDescriptor)
|
||||
(__field.number: @_root_.scala.unchecked) match {
|
||||
case 1 => _root_.scalapb.descriptors.PString(bankId)
|
||||
case 2 => _root_.scalapb.descriptors.PString(accountId)
|
||||
case 3 => _root_.scalapb.descriptors.PString(userId)
|
||||
}
|
||||
}
|
||||
def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
|
||||
def companion = code.obp.grpc.api.BankIdAccountIdAndUserId
|
||||
}
|
||||
|
||||
object BankIdAccountIdAndUserId extends scalapb.GeneratedMessageCompanion[code.obp.grpc.api.BankIdAccountIdAndUserId] {
|
||||
implicit def messageCompanion: scalapb.GeneratedMessageCompanion[code.obp.grpc.api.BankIdAccountIdAndUserId] = this
|
||||
def fromFieldsMap(__fieldsMap: scala.collection.immutable.Map[_root_.com.google.protobuf.Descriptors.FieldDescriptor, scala.Any]): code.obp.grpc.api.BankIdAccountIdAndUserId = {
|
||||
require(__fieldsMap.keys.forall(_.getContainingType() == javaDescriptor), "FieldDescriptor does not match message type.")
|
||||
val __fields = javaDescriptor.getFields
|
||||
code.obp.grpc.api.BankIdAccountIdAndUserId(
|
||||
__fieldsMap.getOrElse(__fields.get(0), "").asInstanceOf[_root_.scala.Predef.String],
|
||||
__fieldsMap.getOrElse(__fields.get(1), "").asInstanceOf[_root_.scala.Predef.String],
|
||||
__fieldsMap.getOrElse(__fields.get(2), "").asInstanceOf[_root_.scala.Predef.String]
|
||||
)
|
||||
}
|
||||
implicit def messageReads: _root_.scalapb.descriptors.Reads[code.obp.grpc.api.BankIdAccountIdAndUserId] = _root_.scalapb.descriptors.Reads{
|
||||
case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
|
||||
require(__fieldsMap.keys.forall(_.containingMessage == scalaDescriptor), "FieldDescriptor does not match message type.")
|
||||
code.obp.grpc.api.BankIdAccountIdAndUserId(
|
||||
__fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""),
|
||||
__fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""),
|
||||
__fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.Predef.String]).getOrElse("")
|
||||
)
|
||||
case _ => throw new RuntimeException("Expected PMessage")
|
||||
}
|
||||
def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = ApiProto.javaDescriptor.getMessageTypes.get(12)
|
||||
def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = ApiProto.scalaDescriptor.messages(12)
|
||||
def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number)
|
||||
lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_]] = Seq.empty
|
||||
def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
|
||||
lazy val defaultInstance = code.obp.grpc.api.BankIdAccountIdAndUserId(
|
||||
)
|
||||
implicit class BankIdAccountIdAndUserIdLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, code.obp.grpc.api.BankIdAccountIdAndUserId]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, code.obp.grpc.api.BankIdAccountIdAndUserId](_l) {
|
||||
def bankId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.bankId)((c_, f_) => c_.copy(bankId = f_))
|
||||
def accountId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.accountId)((c_, f_) => c_.copy(accountId = f_))
|
||||
def userId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.userId)((c_, f_) => c_.copy(userId = f_))
|
||||
}
|
||||
final val BANKID_FIELD_NUMBER = 1
|
||||
final val ACCOUNTID_FIELD_NUMBER = 2
|
||||
final val USERID_FIELD_NUMBER = 3
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
// Generated by the Scala Plugin for the Protocol Buffer Compiler.
|
||||
// Do not edit!
|
||||
//
|
||||
// Protofile syntax: PROTO3
|
||||
|
||||
package code.obp.grpc.api
|
||||
|
||||
@SerialVersionUID(0L)
|
||||
final case class BankIdAndAccountId(
|
||||
bankId: _root_.scala.Predef.String = "",
|
||||
accountId: _root_.scala.Predef.String = ""
|
||||
) extends scalapb.GeneratedMessage with scalapb.Message[BankIdAndAccountId] with scalapb.lenses.Updatable[BankIdAndAccountId] {
|
||||
@transient
|
||||
private[this] var __serializedSizeCachedValue: _root_.scala.Int = 0
|
||||
private[this] def __computeSerializedValue(): _root_.scala.Int = {
|
||||
var __size = 0
|
||||
if (bankId != "") { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, bankId) }
|
||||
if (accountId != "") { __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(2, accountId) }
|
||||
__size
|
||||
}
|
||||
final override def serializedSize: _root_.scala.Int = {
|
||||
var read = __serializedSizeCachedValue
|
||||
if (read == 0) {
|
||||
read = __computeSerializedValue()
|
||||
__serializedSizeCachedValue = read
|
||||
}
|
||||
read
|
||||
}
|
||||
def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
|
||||
{
|
||||
val __v = bankId
|
||||
if (__v != "") {
|
||||
_output__.writeString(1, __v)
|
||||
}
|
||||
};
|
||||
{
|
||||
val __v = accountId
|
||||
if (__v != "") {
|
||||
_output__.writeString(2, __v)
|
||||
}
|
||||
};
|
||||
}
|
||||
def mergeFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): code.obp.grpc.api.BankIdAndAccountId = {
|
||||
var __bankId = this.bankId
|
||||
var __accountId = this.accountId
|
||||
var _done__ = false
|
||||
while (!_done__) {
|
||||
val _tag__ = _input__.readTag()
|
||||
_tag__ match {
|
||||
case 0 => _done__ = true
|
||||
case 10 =>
|
||||
__bankId = _input__.readString()
|
||||
case 18 =>
|
||||
__accountId = _input__.readString()
|
||||
case tag => _input__.skipField(tag)
|
||||
}
|
||||
}
|
||||
code.obp.grpc.api.BankIdAndAccountId(
|
||||
bankId = __bankId,
|
||||
accountId = __accountId
|
||||
)
|
||||
}
|
||||
def withBankId(__v: _root_.scala.Predef.String): BankIdAndAccountId = copy(bankId = __v)
|
||||
def withAccountId(__v: _root_.scala.Predef.String): BankIdAndAccountId = copy(accountId = __v)
|
||||
def getFieldByNumber(__fieldNumber: _root_.scala.Int): scala.Any = {
|
||||
(__fieldNumber: @_root_.scala.unchecked) match {
|
||||
case 1 => {
|
||||
val __t = bankId
|
||||
if (__t != "") __t else null
|
||||
}
|
||||
case 2 => {
|
||||
val __t = accountId
|
||||
if (__t != "") __t else null
|
||||
}
|
||||
}
|
||||
}
|
||||
def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
|
||||
require(__field.containingMessage eq companion.scalaDescriptor)
|
||||
(__field.number: @_root_.scala.unchecked) match {
|
||||
case 1 => _root_.scalapb.descriptors.PString(bankId)
|
||||
case 2 => _root_.scalapb.descriptors.PString(accountId)
|
||||
}
|
||||
}
|
||||
def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
|
||||
def companion = code.obp.grpc.api.BankIdAndAccountId
|
||||
}
|
||||
|
||||
object BankIdAndAccountId extends scalapb.GeneratedMessageCompanion[code.obp.grpc.api.BankIdAndAccountId] {
|
||||
implicit def messageCompanion: scalapb.GeneratedMessageCompanion[code.obp.grpc.api.BankIdAndAccountId] = this
|
||||
def fromFieldsMap(__fieldsMap: scala.collection.immutable.Map[_root_.com.google.protobuf.Descriptors.FieldDescriptor, scala.Any]): code.obp.grpc.api.BankIdAndAccountId = {
|
||||
require(__fieldsMap.keys.forall(_.getContainingType() == javaDescriptor), "FieldDescriptor does not match message type.")
|
||||
val __fields = javaDescriptor.getFields
|
||||
code.obp.grpc.api.BankIdAndAccountId(
|
||||
__fieldsMap.getOrElse(__fields.get(0), "").asInstanceOf[_root_.scala.Predef.String],
|
||||
__fieldsMap.getOrElse(__fields.get(1), "").asInstanceOf[_root_.scala.Predef.String]
|
||||
)
|
||||
}
|
||||
implicit def messageReads: _root_.scalapb.descriptors.Reads[code.obp.grpc.api.BankIdAndAccountId] = _root_.scalapb.descriptors.Reads{
|
||||
case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
|
||||
require(__fieldsMap.keys.forall(_.containingMessage == scalaDescriptor), "FieldDescriptor does not match message type.")
|
||||
code.obp.grpc.api.BankIdAndAccountId(
|
||||
__fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""),
|
||||
__fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).map(_.as[_root_.scala.Predef.String]).getOrElse("")
|
||||
)
|
||||
case _ => throw new RuntimeException("Expected PMessage")
|
||||
}
|
||||
def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = ApiProto.javaDescriptor.getMessageTypes.get(11)
|
||||
def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = ApiProto.scalaDescriptor.messages(11)
|
||||
def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = throw new MatchError(__number)
|
||||
lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_]] = Seq.empty
|
||||
def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
|
||||
lazy val defaultInstance = code.obp.grpc.api.BankIdAndAccountId(
|
||||
)
|
||||
implicit class BankIdAndAccountIdLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, code.obp.grpc.api.BankIdAndAccountId]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, code.obp.grpc.api.BankIdAndAccountId](_l) {
|
||||
def bankId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.bankId)((c_, f_) => c_.copy(bankId = f_))
|
||||
def accountId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.accountId)((c_, f_) => c_.copy(accountId = f_))
|
||||
}
|
||||
final val BANKID_FIELD_NUMBER = 1
|
||||
final val ACCOUNTID_FIELD_NUMBER = 2
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user