Skip to content

Commit

Permalink
Add masterdata provisioning script, finish README
Browse files Browse the repository at this point in the history
  • Loading branch information
wwerner committed Dec 20, 2019
1 parent 1de87ef commit 68e4893
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
18 changes: 13 additions & 5 deletions vlingo-schemata-integration/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ you can also interact with schemata as part of your build process.
In projects, you'll typically consume and/or publish schemata to be able to integrate
with other bounded contexts in a type safe and versioned manner.

This example contains of one project publishing schemata and another one
consuming them as part of their maven build.
In this example, you'll see how to ...

* ... build an run `vlingo/schemata`
* ... manage schemata and schemata meta data using the UI and the HTTP API.
* ... push schemata to the registry from maven builds and
* ... consume schemata stored in the registry as part of the build.
NOTE: This is the first iteration of the example. We're already working on updates showing
version validation and the schemata lifecycle.

== Prerequisites

Expand Down Expand Up @@ -72,8 +80,9 @@ image::doc/ui-browse.png[]

==== Using the API

In case you are using IntelliJ, you can just run the requests in `masterdata.http` directly.
Otherwise, deriving the `curl` footnote:[`PostMan`, `HTTPie`, `wget`, pick your flavor.]
In case you are using IntelliJ, you can just run the requests in `masterdata.http` directly;
`masterdata.sh` is a bash script doing the same footnote:[Requires `curl` and `jq`].
Otherwise, deriving the `wget` footnote:[`PostMan`, `HTTPie`, `Insomnia`, `Invoke-WebRequest` pick your flavor.]
calls from the snippets should be a simple exercise.

== Run
Expand All @@ -97,7 +106,6 @@ NOTE: This is just for illustration purposes. Typically, you'll rely on maven's
that `vlingo-build-plugin` is bound to `generate-sources` and run it before.



[[output-producer]]
.producer build output
[source]
Expand Down
11 changes: 11 additions & 0 deletions vlingo-schemata-integration/masterdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Small utility script to add master data required for the example to a schemata instance
# Requires curl and jq to be on the path.
# Set the port to the port the schemata server is listening on

PORT=9039
ORG_ID=$(curl -s -d '{ "organizationId": "", "name": "Vlingo", "description": "Vlingo Organization" }' -H 'Content-Type: application/json' -X POST http://localhost:${PORT}/organizations | jq -r '.organizationId')
UNIT_ID=$(curl -s -d '{ "organizationId": "'${ORG_ID}'", "unitId": "", "name": "examples", "description": "Examples for vlingo/schemata" }' -X POST -H 'Content-Type: application/json' http://localhost:${PORT}/organizations/${ORG_ID}/units | jq -r '.unitId')
CONTEXT_ID=$(curl -s -X POST -H 'Content-Type: application/json' -d '{ "organizationId": "'${ORG_ID}'", "unitId": "'${UNIT_ID}'", "contextId": "", "namespace": "io.vlingo.examples.schemata", "description": "Bounded context for vlingo/schemata examples" }' http://localhost:${PORT}/organizations/${ORG_ID}/units/${UNIT_ID}/contexts | jq -r '.contextId')
curl -s -X POST -H 'Content-Type: application/json' -d '{ "organizationId": "'${ORG_ID}'", "unitId": "'${UNIT_ID}'", "contextId": "'${CONTEXT_ID}'", "schemaId": "", "category": "Event", "name": "SchemaDefined", "scope": "Public", "description": "Fired whenever a new schema is defined." }' http://localhost:${PORT}/organizations/${ORG_ID}/units/${UNIT_ID}/contexts/${CONTEXT_ID}/schemas
curl -s -X POST -H 'Content-Type: application/json' -d '{ "organizationId": "'${ORG_ID}'", "unitId": "'${UNIT_ID}'", "contextId": "'${CONTEXT_ID}'", "schemaId": "", "category": "Event", "name": "SchemaPublished", "scope": "Public", "description": "Fired whenever a schema version is published." }' http://localhost:${PORT}/organizations/${ORG_ID}/units/${UNIT_ID}/contexts/${CONTEXT_ID}/schemas

0 comments on commit 68e4893

Please sign in to comment.