Skip to content

Instantly share code, notes, and snippets.

@Pentusha
Created February 16, 2017 07:37
Show Gist options
  • Save Pentusha/08de51b973891ff11896daf0ca79d234 to your computer and use it in GitHub Desktop.
Save Pentusha/08de51b973891ff11896daf0ca79d234 to your computer and use it in GitHub Desktop.
#! /bin/bash
BASE_URL='http://0.0.0.0:8000'
USERNAME='testtest'
PASSWORD='testtest'
ENV_NAME='env_dev'
PROJ_NAME='proj_demo'
APP_NAME='app_demo'
HHDEMO_2TABLES='hhdemo_2tables'
auth() {
SESSION_ID=$(
curl \
-s \
-X GET \
-u "$USERNAME:$PASSWORD" \
-G \
-d "env=$ENV_NAME" \
-d "proj=$PROJ_NAME" \
-d "app=$APP_NAME" \
"$BASE_URL/api/v0.6/auth/" \
| jq -r '.api_sessionid'
)
# echo "$SESSION_ID"
}
get_resources_description() {
RESOURCE_DESCRIPTION=$(
curl \
-s \
-X GET \
-b "api_sessionid=$SESSION_ID" \
"$BASE_URL/api/v0.6/resources_description/" \
| jq ".$RESOURCE"
)
echo "$RESOURCE_DESCRIPTION"
}
hhdemo_2tables() {
RESOURCE_OUTPUT=$(
curl \
-s \
-X POST \
-H 'Content-Type: application/json' \
-d '{"@table_fruits": [[111, "ddd"], [222, "ccc"]], "@table_basetypes": [[null, null, null, null, null, null, null, null, null, null, null]]}' \
-b "api_sessionid=$SESSION_ID" \
"$BASE_URL/api/v0.6/table/$HHDEMO_2TABLES/"
)
echo "$RESOURCE_OUTPUT"
}
auth
RESOURCE="$HHDEMO_2TABLES" get_resources_description
hhdemo_2tables
[
[
"basetypes",
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
[
"fruits",
111,
null,
null,
null,
null,
null,
null,
"ddd",
null,
null,
null
],
[
"fruits",
222,
null,
null,
null,
null,
null,
null,
"ccc",
null,
null,
null
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment