Skip to content

Instantly share code, notes, and snippets.

@EricWittmann
Created January 27, 2016 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricWittmann/d28239b5ac2922674c3e to your computer and use it in GitHub Desktop.
Save EricWittmann/d28239b5ac2922674c3e to your computer and use it in GitHub Desktop.
#!/bin/sh
set +x
echo "#"
echo "# Set up a new API in apiman"
echo "#"
set -x
curl --header "Content-Type: application/json" --header "Authorization: BASIC YWRtaW46YWRtaW4xMjMh" -XPOST http://localhost:8080/apiman/organizations -d '{"name":"Test"}'
curl --header "Content-Type: application/json" --header "Authorization: BASIC YWRtaW46YWRtaW4xMjMh" -XPOST http://localhost:8080/apiman/organizations/Test/services -d '
{
"name" : "test-api",
"description" : "Just a test API.",
"initialVersion" : "1.0"
}'
curl --header "Content-Type: application/json" --header "Authorization: BASIC YWRtaW46YWRtaW4xMjMh" -XPUT http://localhost:8080/apiman/organizations/Test/services/test-api/versions/1.0 -d '
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/echo",
"endpointType" : "rest",
"publicService" : true
}'
curl --header "Content-Type: application/json" --header "Authorization: BASIC YWRtaW46YWRtaW4xMjMh" -XPOST http://localhost:8080/apiman/actions -d '
{
"type" : "publishService",
"organizationId" : "Test",
"entityId" : "test-api",
"entityVersion" : "1.0"
}'
set +x
echo "#"
echo "# Checking elasticsearch for appropriate data"
echo "#"
set -x
curl -XGET http://localhost:19200/apiman_gateway/service/Test:test-api:1.0/_source
curl -XGET http://localhost:19200/apiman_gateway/service/_search?pretty=true
set +x
echo "#"
echo "# Hitting the service via the apiman gateway"
echo "#"
set -x
curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/ping
set +x
echo "#"
echo "# Directly modifying elasticsearch data"
echo "#"
set -x
curl --header "Content-Type: application/json" -XPUT http://localhost:19200/apiman_gateway/service/Test:test-api:1.0 -d '
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/status",
"endpointType" : "rest",
"publicService" : true,
"organizationId" : "Example",
"serviceId": "MyService",
"version" : "1.0",
"endpointProperties": [],
"policies":[]
}'
set +x
echo "#"
echo "# Checking elasticsearch for NEW data"
echo "#"
set -x
curl -XGET http://localhost:19200/apiman_gateway/service/Test:test-api:1.0/_source
curl -XGET http://localhost:19200/apiman_gateway/service/_search?pretty=true
set +x
echo "#"
echo "# Hitting the service via the apiman gateway again (should still hit the old endpoint because we haven't restarted apiman yet"
echo "#"
set -x
curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/ping
echo ""
echo ""
echo "Now go ahead and restart apiman and try the service again - it should be using a different endpoint now!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment