From 4820a20b1a0df96054ca210aaa0a89bfa48704e1 Mon Sep 17 00:00:00 2001 From: Madhan Neethiraj <madhan@apache.org> Date: Fri, 25 Aug 2017 16:03:23 -0700 Subject: [PATCH] ATLAS-2088: add dev-test scripts to invoke Atlas REST APIs --- dev-support/atlas-scripts/README.txt | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/admin_status.sh | 40 ++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/classificationdef_get.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_classification_bulk.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_classifications_add.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_classifications_delete.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_classifications_update.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_create.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_delete_by_guid.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_get_by_guid.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_get_by_type_and_unique_attr.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_update.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entity_update_by_type_and_unique_attr.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/entitydef_get.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/enumdef_get.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/env_atlas.sh | 37 +++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/export_entity_by_guid.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/export_entity_by_type_and_attr.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/import_zip.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/sample-data/add_classifications-Employee-1.json | 8 ++++++++ dev-support/atlas-scripts/sample-data/bulk_classification.json | 13 +++++++++++++ dev-support/atlas-scripts/sample-data/entity-create-Employee-1.json | 14 ++++++++++++++ dev-support/atlas-scripts/sample-data/entity-create-Employee-2.json | 14 ++++++++++++++ dev-support/atlas-scripts/sample-data/entity-update-Employee-1.json | 14 ++++++++++++++ dev-support/atlas-scripts/sample-data/search_basic_with_attribute_filters.json | 26 ++++++++++++++++++++++++++ dev-support/atlas-scripts/sample-data/typedefs_create.json | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/sample-data/typedefs_delete.json | 19 +++++++++++++++++++ dev-support/atlas-scripts/sample-data/typedefs_update.json | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/sample-data/update_classifications-Employee-1.json | 8 ++++++++ dev-support/atlas-scripts/search_basic.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/search_basic_with_attribute_filters.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/search_dsl.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/structdef_get.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/typedefs_create.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/typedefs_delete.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/typedefs_get.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ dev-support/atlas-scripts/typedefs_update.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 37 files changed, 1791 insertions(+) create mode 100644 dev-support/atlas-scripts/README.txt create mode 100755 dev-support/atlas-scripts/admin_status.sh create mode 100755 dev-support/atlas-scripts/classificationdef_get.sh create mode 100755 dev-support/atlas-scripts/entity_classification_bulk.sh create mode 100755 dev-support/atlas-scripts/entity_classifications_add.sh create mode 100755 dev-support/atlas-scripts/entity_classifications_delete.sh create mode 100755 dev-support/atlas-scripts/entity_classifications_update.sh create mode 100755 dev-support/atlas-scripts/entity_create.sh create mode 100755 dev-support/atlas-scripts/entity_delete_by_guid.sh create mode 100755 dev-support/atlas-scripts/entity_get_by_guid.sh create mode 100755 dev-support/atlas-scripts/entity_get_by_type_and_unique_attr.sh create mode 100755 dev-support/atlas-scripts/entity_update.sh create mode 100755 dev-support/atlas-scripts/entity_update_by_type_and_unique_attr.sh create mode 100755 dev-support/atlas-scripts/entitydef_get.sh create mode 100755 dev-support/atlas-scripts/enumdef_get.sh create mode 100644 dev-support/atlas-scripts/env_atlas.sh create mode 100755 dev-support/atlas-scripts/export_entity_by_guid.sh create mode 100755 dev-support/atlas-scripts/export_entity_by_type_and_attr.sh create mode 100755 dev-support/atlas-scripts/import_zip.sh create mode 100644 dev-support/atlas-scripts/sample-data/add_classifications-Employee-1.json create mode 100644 dev-support/atlas-scripts/sample-data/bulk_classification.json create mode 100644 dev-support/atlas-scripts/sample-data/entity-create-Employee-1.json create mode 100644 dev-support/atlas-scripts/sample-data/entity-create-Employee-2.json create mode 100644 dev-support/atlas-scripts/sample-data/entity-update-Employee-1.json create mode 100644 dev-support/atlas-scripts/sample-data/search_basic_with_attribute_filters.json create mode 100644 dev-support/atlas-scripts/sample-data/typedefs_create.json create mode 100644 dev-support/atlas-scripts/sample-data/typedefs_delete.json create mode 100644 dev-support/atlas-scripts/sample-data/typedefs_update.json create mode 100644 dev-support/atlas-scripts/sample-data/update_classifications-Employee-1.json create mode 100755 dev-support/atlas-scripts/search_basic.sh create mode 100755 dev-support/atlas-scripts/search_basic_with_attribute_filters.sh create mode 100755 dev-support/atlas-scripts/search_dsl.sh create mode 100755 dev-support/atlas-scripts/structdef_get.sh create mode 100755 dev-support/atlas-scripts/typedefs_create.sh create mode 100755 dev-support/atlas-scripts/typedefs_delete.sh create mode 100755 dev-support/atlas-scripts/typedefs_get.sh create mode 100755 dev-support/atlas-scripts/typedefs_update.sh diff --git a/dev-support/atlas-scripts/README.txt b/dev-support/atlas-scripts/README.txt new file mode 100644 index 0000000..fad84e3 --- /dev/null +++ b/dev-support/atlas-scripts/README.txt @@ -0,0 +1,55 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Shell scripts to make REST calls to Atlas Server using curl. + +1. Update env_atlas.sh with details to contact Atlas Server + +2. Usage of scripts given below: + + -------------------------------------------------------------- + | Command | Arguments + |----------------------------------------|-------------------- + | admin_status.sh + | + | typedefs_create.sh inputFileName + | typedefs_get.sh [outputFileName] + | typedefs_update.sh inputFileName + | typedefs_delete.sh inputFileName + | classificationdef_get.sh typeName [outputFileName] + | entitydef_get.sh typeName [outputFileName] + | enumdef_get.sh typeName [outputFileName] + | structdef_get.sh typeName [outputFileName] + | + | entity_create.sh inputFileName + | entity_get_by_type_and_unique_attr.sh typeName attrName attrValue [outputFileName] + | entity_get_by_guid.sh guid [outputFileName] + | entity_update.sh inputFileName + | entity_update_by_type_and_unique_attr.sh typeName attrName attrValue inputFileName [outputFileName] + | entity_classifications_add.sh guid inputFileName + | entity_classifications_update.sh guid inputFileName + | entity_classifications_delete.sh guid classification + | entity_classification_bulk.sh inputFileName + | entity_delete_by_guid.sh guid + | + | search_basic.sh [queryString] [typeName] [classificationName] [limit] [offset] [outputFileName] + | search_basic_with_attribute_filters.sh inputFileName + | search_dsl.sh queryString [limit] [offset] [outputFileName] + | + | export_entity_by_guid.sh guid [outputFileName] + | export_entity_by_type_and_attr.sh typeName attrName attrValue [matchType] [fetchType] [outputFileName] + | import_zip.sh inputFileName + -----------------------------------------|-------------------- diff --git a/dev-support/atlas-scripts/admin_status.sh b/dev-support/atlas-scripts/admin_status.sh new file mode 100755 index 0000000..21b08dd --- /dev/null +++ b/dev-support/atlas-scripts/admin_status.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# +# Get status of Atlas server +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +url=${ATLAS_URL}/api/atlas/admin/status + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/classificationdef_get.sh b/dev-support/atlas-scripts/classificationdef_get.sh new file mode 100755 index 0000000..a07130c --- /dev/null +++ b/dev-support/atlas-scripts/classificationdef_get.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an classification-def by name +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +outputFileName=$2 + +function checkUsage() { + if [ "${typeName}" == "" ] + then + echo "Usage: $0 type-name [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "classificationdef-${typeName}.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/classificationdef/name/${typeName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_classification_bulk.sh b/dev-support/atlas-scripts/entity_classification_bulk.sh new file mode 100755 index 0000000..0dcaeb8 --- /dev/null +++ b/dev-support/atlas-scripts/entity_classification_bulk.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Add a classification to mutiple entities +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 inputFileName" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity/bulk/classification + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url} -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_classifications_add.sh b/dev-support/atlas-scripts/entity_classifications_add.sh new file mode 100755 index 0000000..31f06f0 --- /dev/null +++ b/dev-support/atlas-scripts/entity_classifications_add.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Add classifications to an entity +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 +inputFileName=$2 + +function checkUsage() { + if [ "${guid}" == "" -o "${inputFileName}" == "" ] + then + echo "Usage: $0 guid inputFileName" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/entity/guid/${guid}/classifications -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" + echo "${output}" +fi diff --git a/dev-support/atlas-scripts/entity_classifications_delete.sh b/dev-support/atlas-scripts/entity_classifications_delete.sh new file mode 100755 index 0000000..c9b320b --- /dev/null +++ b/dev-support/atlas-scripts/entity_classifications_delete.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Remove a classification of an entity +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 +classification=$2 + +function checkUsage() { + if [ "${guid}" == "" -o "${classification}" == "" ] + then + echo "Usage: $0 guid classification" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X DELETE -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/entity/guid/${guid}/classification/${classification}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" + echo "${output}" +fi diff --git a/dev-support/atlas-scripts/entity_classifications_update.sh b/dev-support/atlas-scripts/entity_classifications_update.sh new file mode 100755 index 0000000..c4e6747 --- /dev/null +++ b/dev-support/atlas-scripts/entity_classifications_update.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Update classifications of an entity +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 +inputFileName=$2 + +function checkUsage() { + if [ "${guid}" == "" -o "${inputFileName}" == "" ] + then + echo "Usage: $0 guid inputFileName" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X PUT -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/entity/guid/${guid}/classifications -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" + echo "${output}" +fi diff --git a/dev-support/atlas-scripts/entity_create.sh b/dev-support/atlas-scripts/entity_create.sh new file mode 100755 index 0000000..9cbead1 --- /dev/null +++ b/dev-support/atlas-scripts/entity_create.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Create an entity +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 inputFileName" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url} -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" + echo "${output}" +fi diff --git a/dev-support/atlas-scripts/entity_delete_by_guid.sh b/dev-support/atlas-scripts/entity_delete_by_guid.sh new file mode 100755 index 0000000..cbfb4e9 --- /dev/null +++ b/dev-support/atlas-scripts/entity_delete_by_guid.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Delete an entity given its guid +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 + +function checkUsage() { + if [ "${guid}" == "" ] + then + echo "Usage: $0 guid" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity/guid/${guid} + +output=`${CURL_CMDLINE} -X DELETE -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_get_by_guid.sh b/dev-support/atlas-scripts/entity_get_by_guid.sh new file mode 100755 index 0000000..658ac6a --- /dev/null +++ b/dev-support/atlas-scripts/entity_get_by_guid.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an entity by guid +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 +outputFileName=$2 + + +function checkUsage() { + if [ "${guid}" == "" ] + then + echo "Usage: $0 guid [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "entity-${guid}.json"` + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity/guid/${guid} + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_get_by_type_and_unique_attr.sh b/dev-support/atlas-scripts/entity_get_by_type_and_unique_attr.sh new file mode 100755 index 0000000..cdfac87 --- /dev/null +++ b/dev-support/atlas-scripts/entity_get_by_type_and_unique_attr.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an entity by type and unique attribute +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +attrName=$2 +attrValue=$3 +outputFileName=$4 + + +function checkUsage() { + if [ "${typeName}" == "" -o "${attrName}" == "" -o "${attrValue}" == "" ] + then + echo "Usage: $0 typeName attrName attrValue [outputFileName]" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity/uniqueAttribute/type/${typeName}?attr:${attrName}=${attrValue} + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url}` +ret=$? + +if [ $ret == 0 ] +then + if [ "${outputFileName}" == "" ] + then + echo ${output} | ${JSON_FORMATTER} + else + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" + fi +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_update.sh b/dev-support/atlas-scripts/entity_update.sh new file mode 100755 index 0000000..c917db9 --- /dev/null +++ b/dev-support/atlas-scripts/entity_update.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Update an entity +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 inputFileName" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url} -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entity_update_by_type_and_unique_attr.sh b/dev-support/atlas-scripts/entity_update_by_type_and_unique_attr.sh new file mode 100755 index 0000000..29b2439 --- /dev/null +++ b/dev-support/atlas-scripts/entity_update_by_type_and_unique_attr.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Update an entity by type and unique attribute +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +attrName=$2 +attrValue=$3 +inputFileName=$4 +outputFileName=$5 + + +function checkUsage() { + if [ "${typeName}" == "" -o "${attrName}" == "" -o "${attrValue}" == "" -o "${inputFileName}" == "" ] + then + echo "Usage: $0 typeName attrName attrValue inputFileName [outputFileName]" + exit 1 + fi +} +checkUsage + +url=${ATLAS_URL}/api/atlas/v2/entity/uniqueAttribute/type/${typeName}/attribute/${attrName}?value=${attrValue} + +output=`${CURL_CMDLINE} -X PUT -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${url} -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + if [ "${outputFileName}" == "" ] + then + echo ${output} | ${JSON_FORMATTER} + else + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" + fi +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/entitydef_get.sh b/dev-support/atlas-scripts/entitydef_get.sh new file mode 100755 index 0000000..1d0ce26 --- /dev/null +++ b/dev-support/atlas-scripts/entitydef_get.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an entity-def by name +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +outputFileName=$2 + +function checkUsage() { + if [ "${typeName}" == "" ] + then + echo "Usage: $0 type-name [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "entitydef-${typeName}.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/entitydef/name/${typeName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/enumdef_get.sh b/dev-support/atlas-scripts/enumdef_get.sh new file mode 100755 index 0000000..4b53a3c --- /dev/null +++ b/dev-support/atlas-scripts/enumdef_get.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an enum-def by name +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +outputFileName=$2 + +function checkUsage() { + if [ "${typeName}" == "" ] + then + echo "Usage: $0 type-name [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "enumdef-${typeName}.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/enumdef/name/${typeName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/env_atlas.sh b/dev-support/atlas-scripts/env_atlas.sh new file mode 100644 index 0000000..4bcd5e5 --- /dev/null +++ b/dev-support/atlas-scripts/env_atlas.sh @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +export ATLAS_URL=http://localhost:21000 +export ATLAS_USER=username +export ATLAS_PASS=password + +export JSON_FORMATTER="python -mjson.tool" +export CURL_CMDLINE="curl -f " + +export DATA_DIR=data + +if [ ! -d ${DATA_DIR} ] +then + mkdir -p ${DATA_DIR} +fi + +function getDataFilePath() { + local fileName=$1 + + echo "${DATA_DIR}/${fileName}" +} diff --git a/dev-support/atlas-scripts/export_entity_by_guid.sh b/dev-support/atlas-scripts/export_entity_by_guid.sh new file mode 100755 index 0000000..480ff10 --- /dev/null +++ b/dev-support/atlas-scripts/export_entity_by_guid.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# +# Export an entity by guid +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +guid=$1 +outputFileName=$2 + + +function checkUsage() { + if [ "${guid}" == "" ] + then + echo "Usage: $0 guid [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "export-${guid}.zip"` + fi +} +checkUsage + +postBody="{ \"itemsToExport\": [ { \"guid\": \"${guid}\" } ] }" + +tmpFileName=/tmp/export_$$.txt + +echo ${postBody} >> ${tmpFileName} + +${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/zip" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/admin/export -d @${tmpFileName} > ${outputFileName} +ret=$? + +if [ $ret == 0 ] +then + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/export_entity_by_type_and_attr.sh b/dev-support/atlas-scripts/export_entity_by_type_and_attr.sh new file mode 100755 index 0000000..01a0ce7 --- /dev/null +++ b/dev-support/atlas-scripts/export_entity_by_type_and_attr.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Export an entity by type and given attr=value +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +attrName=$2 +attrValue=$3 +matchType=$4 +fetchType=$5 +outputFileName=$6 + + +function checkUsage() { + if [ "${typeName}" == "" -o "${attrName}" == "" -o "${attrValue}" == "" ] + then + echo "Usage: $0 typeName attrName attrValue [matchType] [fetchType] [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "export-${typeName}-${attrName}.zip"` + fi + + if [ "${matchType}" == "" ] + then + matchType="equals" + fi + + if [ "${fetchType}" == "" ] + then + fetchType="connected" + fi +} +checkUsage + +postBody="{ \"itemsToExport\": [ { \"typeName\": \"${typeName}\", \"uniqueAttributes\": { \"${attrName}\": \"${attrValue}\" } } ], \"options\": { \"matchType\":\"${matchType}\", \"fetchType\":\"${fetchType}\" }}" + +tmpFileName=/tmp/export_$$.txt + +echo ${postBody} >> ${tmpFileName} + +${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/zip" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/admin/export -d @${tmpFileName} > ${outputFileName} +ret=$? + +if [ $ret == 0 ] +then + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/import_zip.sh b/dev-support/atlas-scripts/import_zip.sh new file mode 100755 index 0000000..90a4dc9 --- /dev/null +++ b/dev-support/atlas-scripts/import_zip.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Import entities from a zip file created by export +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 inputFileName" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: multipart/form-data" -H "Cache-Control: no-cache" -F data=@${inputFileName} request="" ${ATLAS_URL}/api/atlas/admin/import` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} + echo "imported from ${inputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/sample-data/add_classifications-Employee-1.json b/dev-support/atlas-scripts/sample-data/add_classifications-Employee-1.json new file mode 100644 index 0000000..561174f --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/add_classifications-Employee-1.json @@ -0,0 +1,8 @@ +[ + { + "typeName": "PII", + "attributes": { + "type": "ccn" + } + } +] diff --git a/dev-support/atlas-scripts/sample-data/bulk_classification.json b/dev-support/atlas-scripts/sample-data/bulk_classification.json new file mode 100644 index 0000000..dae0946 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/bulk_classification.json @@ -0,0 +1,13 @@ +{ + "classification": { + "typeName": "FINANCE_PII", + "attributes": { + "type": "ccn", + "notes": "bulk-add" + } + }, + "entityGuids": [ + "2f57519a-4ec2-4a0f-b37f-59aeee72a338", + "dba348f9-bea2-45cc-bbca-38be48855ce3" + ] +} diff --git a/dev-support/atlas-scripts/sample-data/entity-create-Employee-1.json b/dev-support/atlas-scripts/sample-data/entity-create-Employee-1.json new file mode 100644 index 0000000..10e392a --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/entity-create-Employee-1.json @@ -0,0 +1,14 @@ +{ + "entity": { + "typeName": "Employee", + "attributes": { + "qualifiedName": "Employee-1", + "name": "John Doe", + "emailAddress": "john.doe@EXAMPLE.COM", + "createdBy": "admin", + "createTime": "2017-08-25T13:15:25.369Z", + "updatedBy": "admin", + "updateTime": "2017-08-25T14:12:45.246Z" + } + } +} diff --git a/dev-support/atlas-scripts/sample-data/entity-create-Employee-2.json b/dev-support/atlas-scripts/sample-data/entity-create-Employee-2.json new file mode 100644 index 0000000..b3d1d9f --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/entity-create-Employee-2.json @@ -0,0 +1,14 @@ +{ + "entity": { + "typeName": "Employee", + "attributes": { + "qualifiedName": "Employee-2", + "name": "Anna Scott", + "emailAddress": "anna.scott@EXAMPLE.COM", + "createdBy": "admin", + "createTime": "2017-08-25T14:14:24.349Z", + "updatedBy": "admin", + "updateTime": "2017-08-25T15:13:46.256Z" + } + } +} diff --git a/dev-support/atlas-scripts/sample-data/entity-update-Employee-1.json b/dev-support/atlas-scripts/sample-data/entity-update-Employee-1.json new file mode 100644 index 0000000..dab73f2 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/entity-update-Employee-1.json @@ -0,0 +1,14 @@ +{ + "entity": { + "typeName": "Employee", + "attributes": { + "qualifiedName": "Employee-1", + "name": "John Doe", + "emailAddress": "john.doe@johndoe.com", + "createdBy": "admin", + "createTime": "2017-08-25T13:15:25.369Z", + "updatedBy": "admin", + "updateTime": "2017-08-25T15:13:43.246Z" + } + } +} diff --git a/dev-support/atlas-scripts/sample-data/search_basic_with_attribute_filters.json b/dev-support/atlas-scripts/sample-data/search_basic_with_attribute_filters.json new file mode 100644 index 0000000..cfd8dd3 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/search_basic_with_attribute_filters.json @@ -0,0 +1,26 @@ +{ + "query": "", + "typeName": "Employee", + "classification": "PII", + "excludeDeletedEntities": true, + "entityFilters": { + "attributeName": "name", + "operator": "startsWith", + "attributeValue": "Anna" + }, + "tagFilters": { + "condition": "AND", + "criterion": [ + { + "attributeName": "type", + "operator": "=", + "attributeValue": "ccn" + }, + { + "attributeName": "notes", + "operator": "contains", + "attributeValue": "bulk" + } + ] + } +} diff --git a/dev-support/atlas-scripts/sample-data/typedefs_create.json b/dev-support/atlas-scripts/sample-data/typedefs_create.json new file mode 100644 index 0000000..bef5ced --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/typedefs_create.json @@ -0,0 +1,136 @@ +{ + "enumDefs": [ + { + "name": "pii_type", + "category": "ENUM", + "elementDefs": [ + { "ordinal": 1, "value": "ccn" }, + { "ordinal": 2, "value": "ssn" }, + { "ordinal": 3, "value": "mrn" } + ] + } + ], + + "structDefs": [ + { + "name": "point_2d", + "category": "STRUCT", + "attributeDefs": [ + { + "name": "x", + "typeName": "int", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + }, + { + "name": "y", + "typeName": "int", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + } + ] + } + ], + + "classificationDefs": [ + { + "name": "PII", + "category": "CLASSIFICATION", + "superTypes": [], + "attributeDefs": [ + { + "name": "type", + "typeName": "pii_type", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": true, + "isUnique": false + } + ] + }, + { + "name": "FINANCE_PII", + "category": "CLASSIFICATION", + "superTypes": [ "PII" ], + "attributeDefs": [ + { + "name": "notes", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": true, + "isUnique": false + } + ] + }, + { + "name": "VENDOR_PII", + "category": "CLASSIFICATION", + "superTypes": [ "PII" ], + "attributeDefs": [ + { + "name": "notes", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": true, + "isUnique": false + } + ] + } + ], + + "entityDefs": [ + { + "name": "Employee", + "category": "ENTITY", + "superTypes": [ "Referenceable" ], + "attributeDefs": [ + { + "name": "name", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + }, + { + "name": "createTime", + "typeName": "date", + "cardinality": "SINGLE", + "isIndexable": true, + "isOptional": false, + "isUnique": false + }, + { + "name": "createdBy", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + }, + { + "name": "updateTime", + "typeName": "date", + "cardinality": "SINGLE", + "isIndexable": true, + "isOptional": false, + "isUnique": false + }, + { + "name": "updatedBy", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + } + ] + } + ] +} diff --git a/dev-support/atlas-scripts/sample-data/typedefs_delete.json b/dev-support/atlas-scripts/sample-data/typedefs_delete.json new file mode 100644 index 0000000..08fac11 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/typedefs_delete.json @@ -0,0 +1,19 @@ +{ + "enumDefs": [ + { "name": "pii_type" } + ], + + "structDefs": [ + { "name": "point_2d" } + ], + + "classificationDefs": [ + { "name": "PII" }, + { "name": "FINANCE_PII" }, + { "name": "VENDOR_PII" } + ], + + "entityDefs": [ + { "name": "Employee" } + ] +} diff --git a/dev-support/atlas-scripts/sample-data/typedefs_update.json b/dev-support/atlas-scripts/sample-data/typedefs_update.json new file mode 100644 index 0000000..3fcfdc4 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/typedefs_update.json @@ -0,0 +1,65 @@ +{ + "enumDefs": [ ], + + "structDefs": [ ], + + "classificationDefs": [ ], + + "entityDefs": [ + { + "name": "Employee", + "category": "ENTITY", + "superTypes": [ "Referenceable" ], + "attributeDefs": [ + { + "name": "name", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + }, + { + "name": "emailAddress", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": true, + "isUnique": false + }, + { + "name": "createTime", + "typeName": "date", + "cardinality": "SINGLE", + "isIndexable": true, + "isOptional": false, + "isUnique": false + }, + { + "name": "createdBy", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + }, + { + "name": "updateTime", + "typeName": "date", + "cardinality": "SINGLE", + "isIndexable": true, + "isOptional": false, + "isUnique": false + }, + { + "name": "updatedBy", + "typeName": "string", + "cardinality": "SINGLE", + "isIndexable": false, + "isOptional": false, + "isUnique": false + } + ] + } + ] +} diff --git a/dev-support/atlas-scripts/sample-data/update_classifications-Employee-1.json b/dev-support/atlas-scripts/sample-data/update_classifications-Employee-1.json new file mode 100644 index 0000000..61a0ec7 --- /dev/null +++ b/dev-support/atlas-scripts/sample-data/update_classifications-Employee-1.json @@ -0,0 +1,8 @@ +[ + { + "typeName": "PII", + "attributes": { + "type": "mrn" + } + } +] diff --git a/dev-support/atlas-scripts/search_basic.sh b/dev-support/atlas-scripts/search_basic.sh new file mode 100755 index 0000000..9ff16f2 --- /dev/null +++ b/dev-support/atlas-scripts/search_basic.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# perform a basic search +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +query=$1 +typeName=$2 +classificationName=$3 +limit=$4 +offset=$5 +outputFileName=$6 + +function checkUsage() { + if [ "${query}" == "" -a "${typeName}" == "" -a "${classificationName}" == "" ] + then + echo "Usage: $0 query typeName classificationName [limit] [offset] [outputFileName]" + exit 1 + fi + + if [ "${limit}" == "" ] + then + limit=-1 + fi + + if [ "${offset}" == "" ] + then + offset=-1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "search-basic.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/search/basic?query="${query}"\&typeName="${typeName}"\&classification="${classificationName}"\&excludeDeletedEntities=true\&limit=${limit}\&offset=${offset}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/search_basic_with_attribute_filters.sh b/dev-support/atlas-scripts/search_basic_with_attribute_filters.sh new file mode 100755 index 0000000..ba20d02 --- /dev/null +++ b/dev-support/atlas-scripts/search_basic_with_attribute_filters.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# perform a basic search with attribute filtering +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 +outputFileName=$2 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 inputFileName [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "earch_basic_with_attribute_filters.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/search/basic -d @${inputFileName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" + echo "${output}" +fi diff --git a/dev-support/atlas-scripts/search_dsl.sh b/dev-support/atlas-scripts/search_dsl.sh new file mode 100755 index 0000000..6b3e170 --- /dev/null +++ b/dev-support/atlas-scripts/search_dsl.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# perform a DSL search +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +query=$1 +limit=$2 +offset=$3 +outputFileName=$4 + +function checkUsage() { + if [ "${query}" == "" ] + then + echo "Usage: $0 query [limit] [offset] [outputFileName]" + exit 1 + fi + + if [ "${limit}" == "" ] + then + limit=-1 + fi + + if [ "${offset}" == "" ] + then + offset=-1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "search-dsl.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/search/dsl?query="${query}"\&limit=${limit}\&offset=${offset}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/structdef_get.sh b/dev-support/atlas-scripts/structdef_get.sh new file mode 100755 index 0000000..aa3ba20 --- /dev/null +++ b/dev-support/atlas-scripts/structdef_get.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get an struct-def by name +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +typeName=$1 +outputFileName=$2 + +function checkUsage() { + if [ "${typeName}" == "" ] + then + echo "Usage: $0 type-name [outputFileName]" + exit 1 + fi + + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "structdef-${typeName}.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/structdef/name/${typeName}` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/typedefs_create.sh b/dev-support/atlas-scripts/typedefs_create.sh new file mode 100755 index 0000000..351fad6 --- /dev/null +++ b/dev-support/atlas-scripts/typedefs_create.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Create typedefs +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 input-file" + exit 1 + fi + + if [ ! -f "${inputFileName}" ] + then + echo "${inputFileName}: does not exist" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X POST -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/typedefs -d @${inputFileName}` +ret=$? + + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/typedefs_delete.sh b/dev-support/atlas-scripts/typedefs_delete.sh new file mode 100755 index 0000000..d6056f5 --- /dev/null +++ b/dev-support/atlas-scripts/typedefs_delete.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Delete typedefs +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 input-file" + exit 1 + fi + + if [ ! -f "${inputFileName}" ] + then + echo "${inputFileName}: does not exist" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X DELETE -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/typedefs -d @${inputFileName}` +ret=$? + + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/typedefs_get.sh b/dev-support/atlas-scripts/typedefs_get.sh new file mode 100755 index 0000000..3c63940 --- /dev/null +++ b/dev-support/atlas-scripts/typedefs_get.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Get all typedefs +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +outputFileName=$1 + +function checkUsage() { + if [ "${outputFileName}" == "" ] + then + outputFileName=`getDataFilePath "typedefs.json"` + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X GET -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/typedefs` +ret=$? + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} | tee ${outputFileName} + echo "saved to ${outputFileName}" +else + echo "failed with error code: ${ret}" +fi diff --git a/dev-support/atlas-scripts/typedefs_update.sh b/dev-support/atlas-scripts/typedefs_update.sh new file mode 100755 index 0000000..abe0b5f --- /dev/null +++ b/dev-support/atlas-scripts/typedefs_update.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Update typedefs +# + +realScriptDir=$(cd "$(dirname "$0")"; pwd) + +source ${realScriptDir}/env_atlas.sh +source ./env_atlas.sh + +inputFileName=$1 + +function checkUsage() { + if [ "${inputFileName}" == "" ] + then + echo "Usage: $0 input-file" + exit 1 + fi + + if [ ! -f "${inputFileName}" ] + then + echo "${inputFileName}: does not exist" + exit 1 + fi +} +checkUsage + +output=`${CURL_CMDLINE} -X PUT -u ${ATLAS_USER}:${ATLAS_PASS} -H "Accept: application/json" -H "Content-Type: application/json" ${ATLAS_URL}/api/atlas/v2/types/typedefs -d @${inputFileName}` +ret=$? + + +if [ $ret == 0 ] +then + echo ${output} | ${JSON_FORMATTER} +else + echo "failed with error code: ${ret}" +fi -- libgit2 0.27.1