Skip to content

Commit

Permalink
Merge pull request #117 from ostelco/develop
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
mpeterss authored May 18, 2018
2 parents 95a4c11 + 985f46c commit 25de7df
Show file tree
Hide file tree
Showing 170 changed files with 4,307 additions and 746 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Compiled class file
*.class

.classpath
.project
.settings

# Log file
*.log

Expand Down
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
language: java

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

before_install:
- sudo apt-get install jq
Expand All @@ -11,4 +16,4 @@ before_install:
- wget -O ~/codacy-coverage-reporter-assembly-latest.jar https://github.com/codacy/codacy-coverage-reporter/releases/download/4.0.0/codacy-coverage-reporter-4.0.0-assembly.jar

after_success:
- java -cp ~/codacy-coverage-reporter-assembly-latest.jar com.codacy.CodacyCoverageReporter -l Java -r prime/build/reports/jacoco/test/jacocoTestReport.xml
- java -cp ~/codacy-coverage-reporter-assembly-latest.jar com.codacy.CodacyCoverageReporter report -l Java -r prime/build/reports/jacoco/test/jacocoTestReport.xml
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# ostelco-core

[![Build Status](https://travis-ci.org/ostelco/ostelco-core.svg?branch=master)](https://travis-ci.org/ostelco/ostelco-core) [![codebeat badge](https://codebeat.co/badges/e4c26ba7-75d6-48d2-a3d0-f72988998642)](https://codebeat.co/projects/github-com-ostelco-ostelco-core-master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/e7b2ae0440104a5e8ae6fa5e919147dc)](https://www.codacy.com/app/la3lma/ostelco-core?utm_source=github.com&utm_medium=referral&utm_content=ostelco/ostelco-core&utm_campaign=Badge_Grade)[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/e7b2ae0440104a5e8ae6fa5e919147dc)](https://www.codacy.com/app/la3lma/ostelco-core?utm_source=github.com&utm_medium=referral&utm_content=ostelco/ostelco-core&utm_campaign=Badge_Coverage)
Mono Repository for core protocols and services around a OCS/BSS for packet data. For each service please see the individual Readme.md files.

[general documentation](./docs/README.md)

[analytics](./analytics/README.md)

[auth-server](./auth-server/README.md)

[diameter-stack](./diameter-stack/README.md)

[diameter-test](./diameter-test/README.md)

[exporter](./exporter/README.md)

[ext-pgw](./ext-pgw/README.md)

[ocs-api](./ocs-api/README.md)

[ocsgw](./ocsgw/README.md)

[ostelco-lib](./ostelco-lib/README.md)

[prime](./prime/README.md)

[pseudonym-server](./pseudonym-server/README.md)

[seagull](./seagull/README.md)

[![Build Status](https://travis-ci.org/ostelco/ostelco-core.svg?branch=master)](https://travis-ci.org/ostelco/ostelco-core) [![codebeat badge](https://codebeat.co/badges/e4c26ba7-75d6-48d2-a3d0-f72988998642)](https://codebeat.co/projects/github-com-ostelco-ostelco-core-master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/e7b2ae0440104a5e8ae6fa5e919147dc)](https://www.codacy.com/app/la3lma/ostelco-core?utm_source=github.com&utm_medium=referral&utm_content=ostelco/ostelco-core&utm_campaign=Badge_Grade)[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/e7b2ae0440104a5e8ae6fa5e919147dc)](https://www.codacy.com/app/la3lma/ostelco-core?utm_source=github.com&utm_medium=referral&utm_content=ostelco/ostelco-core&utm_campaign=Badge_Coverage)

Core protocols and services
50 changes: 50 additions & 0 deletions admin-api/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Admin API

* Admin API is for back-office admin management.
* Each of the _Resources_ are listed below shall have Create-Read-Update-Delete operations.

### Product Class

id: <product class id>
properties:
<multi-level template>

### Product

##### Product for Client API

sku: <product sku>
class: <product class id>
price:
amount: <amount>
currency: <currency code>
properties:
<multi-level object>

##### Additional attributes of Product for Admin API

visibility:
flag: <boolean>
start_date: <datetime>
end_date: <datetime>

### Segment

id: <segment id>
description: <optional human understandable text>
export_id: <export id used to de-anonymize subscriber ids>
type: <EXTERNAL or CONDITIONAL>
subscribers:
<list of subscribers - for type=EXTERNAL only>
condition: <boolean expression - for type=CONDITIONAL>

### Offer

id: <offer id>
segment_id: <segment id>
products:
<list of products>
validity (visibility):
start_date: <start date of an offer>
end_date: <end date of an offer>

13 changes: 13 additions & 0 deletions admin-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id "java-library"
id "org.jetbrains.kotlin.jvm" version "1.2.41"
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation project(":prime-api")
implementation "io.dropwizard:dropwizard-auth:$dropwizardVersion"

testImplementation "io.dropwizard:dropwizard-testing:$dropwizardVersion"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.ostelco.prime.admin.api

import com.fasterxml.jackson.annotation.JsonTypeName
import io.dropwizard.setup.Environment
import org.ostelco.prime.getResource
import org.ostelco.prime.provider.Service
import org.ostelco.prime.storage.DataStore

@JsonTypeName("admin")
class AdminService: Service {

private var datastore: DataStore = getResource()

override fun init(env: Environment) {
val jerseySever = env.jersey()
jerseySever.register(OfferResource(datastore))
jerseySever.register(SegmentResource(datastore))
jerseySever.register(ProductResource(datastore))
jerseySever.register(ProductClassResource(datastore))
}
}
14 changes: 14 additions & 0 deletions admin-api/src/main/kotlin/org/ostelco/prime/admin/api/Model.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.ostelco.prime.admin.api

import org.ostelco.prime.model.Entity

class Offer : Entity {
override var id: String = ""
var segments: Array<String> = emptyArray()
var products: Array<String> = emptyArray()
}

class Segment : Entity {
override var id: String = ""
var subscribers: Array<String> = emptyArray()
}
101 changes: 101 additions & 0 deletions admin-api/src/main/kotlin/org/ostelco/prime/admin/api/Resources.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.ostelco.prime.admin.api


import org.ostelco.prime.model.AdminProduct
import org.ostelco.prime.model.ProductClass
import org.ostelco.prime.storage.DataStore
import javax.ws.rs.GET
import javax.ws.rs.POST
import javax.ws.rs.PUT
import javax.ws.rs.Path
import javax.ws.rs.PathParam

@Path("/offers")
class OfferResource(private val dataStore: DataStore) {

@GET
fun getOffers() = dataStore.getOffers().map { it.id }

@GET
@Path("/{offer-id}")
fun getOffer(@PathParam("offer-id") offerId: String) = dataStore.getOffer(offerId)

@POST
fun createOffer(offer: Offer) = dataStore.createOffer(toStoredOffer(offer))

private fun toStoredOffer(offer: Offer): org.ostelco.prime.model.Offer {
val storedOffer = org.ostelco.prime.model.Offer()
storedOffer.id = offer.id
storedOffer.segments = offer.segments.map { dataStore.getSegment(it) }.requireNoNulls()
storedOffer.products = offer.products.map { dataStore.getProduct(it) }.requireNoNulls()
return storedOffer
}
}

@Path("/segments")
class SegmentResource(private val dataStore: DataStore) {

@GET
fun getSegments() = dataStore.getSegments().map { it.id }

@GET
@Path("/{segment-id}")
fun getSegment(@PathParam("segment-id") segmentId: String) = dataStore.getSegment(segmentId)

@POST
fun createSegment(segment: Segment) = dataStore.createSegment(toStoredSegment(segment))

@PUT
@Path("/{segment-id}")
fun updateSegment(
@PathParam("segment-id") segmentId: String,
segment: Segment): Boolean {
segment.id = segmentId
return dataStore.updateSegment(toStoredSegment(segment))
}

private fun toStoredSegment(segment: Segment): org.ostelco.prime.model.Segment {
val storedSegment = org.ostelco.prime.model.Segment()
storedSegment.id = segment.id
storedSegment.subscribers = segment.subscribers.map { dataStore.getSubscriber(it) }.requireNoNulls()
return storedSegment
}
}

@Path("/products")
class ProductResource(private val dataStore: DataStore) {

@GET
fun getProducts() = dataStore.getProducts().map { it.id }

@GET
@Path("/{product-sku}")
fun getProducts(@PathParam("product-sku") productSku: String) = dataStore.getProduct(productSku)

@POST
fun createProduct(product: AdminProduct) = dataStore.createProduct(product)
}

@Path("/product_classes")
class ProductClassResource(private val dataStore: DataStore) {

@GET
fun getProductClasses() = dataStore.getProductClasses().map { it.id }

@GET
@Path("/{product-class-id}")
fun getProductClass(@PathParam("product-class-id") productClassId: String)
= dataStore.getProductClass(productClassId)

@POST
fun createProductClass(productClass: ProductClass) = dataStore.createProductClass(productClass)

@PUT
@Path("/{product-class-id}")
fun updateProductClass(
@PathParam("product-class-id") productClassId: String,
productClass: ProductClass): Boolean {
productClass.id = productClassId
return dataStore.updateProductClass(productClass)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.ostelco.prime.provider.Service
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.ostelco.prime.admin.api.AdminService
6 changes: 3 additions & 3 deletions analytics/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id "application"
id "jacoco"
id "com.github.johnrengelman.shadow" version "2.0.3"
id "org.jetbrains.kotlin.jvm" version "1.2.31"
id "com.github.johnrengelman.shadow" version "2.0.4"
id "org.jetbrains.kotlin.jvm" version "1.2.41"
id "idea"
}

dependencies {
implementation project(':ocs-api')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation 'com.google.cloud:google-cloud-pubsub:0.44.0-beta'
implementation 'com.google.cloud:google-cloud-pubsub:0.46.0-beta'
implementation 'com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:2.4.0'
runtime 'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.4.0'
implementation 'ch.qos.logback:logback-classic:1.2.3'
Expand Down
11 changes: 6 additions & 5 deletions auth-server/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Auth Server

Path: /auth/token
Port: 8080
Method: GET
Header: X-MSISDN - Will be header injected by PGw.
Response: JWT Firebase Token for given MSISDN.

Path: /auth/token
Port: 8080
Method: GET
Header: X-MSISDN - Will be header injected by P-GW.
Response: JWT Firebase Token for given MSISDN.
6 changes: 3 additions & 3 deletions auth-server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id "application"
id "jacoco"
id "com.github.johnrengelman.shadow" version "2.0.3"
id "org.jetbrains.kotlin.jvm" version "1.2.31"
id "com.github.johnrengelman.shadow" version "2.0.4"
id "org.jetbrains.kotlin.jvm" version "1.2.41"
id "idea"
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation "io.dropwizard:dropwizard-core:$dropwizardVersion"
implementation 'com.google.firebase:firebase-admin:5.10.0'
implementation 'com.google.firebase:firebase-admin:5.11.0'
testImplementation "io.dropwizard:dropwizard-testing:$dropwizardVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
testRuntime 'org.hamcrest:hamcrest-all:1.3'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ subprojects {
options.encoding = 'UTF-8'
}
ext {
kotlinVersion = "1.2.31"
kotlinVersion = "1.2.41"
dropwizardVersion = "1.3.1"
}
}
Expand Down
4 changes: 4 additions & 0 deletions client-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin/
*.orig.*
*.toc.*
pom.xml
Loading

0 comments on commit 25de7df

Please sign in to comment.