Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ioh/tutorial edit suggestions #55

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions qlik.dev/tutorials/platform-operations/cli-bash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementations of various tutorials from [Qlik Platform Operations tutorials](https://qlik.dev/manage/platform-operations/overview) on [qlik.dev](http://qlik.dev).

### Prerequisites

* Bash 5.1 or higher
* [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) version `2.14.3` or higher is installed.
* [The JQ command-line JSON processor](https://github.com/stedolan/jq/wiki/Installation) is installed.
Expand All @@ -11,6 +12,7 @@ Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementation
### Running

* [Create a tenant](https://qlik.dev/tutorials/create-a-tenant), example usage:

```bash
./tenant_create.sh \
--client-id <CLIENT_ID> \
Expand All @@ -21,6 +23,7 @@ Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementation
```

* [Configure a tenant](https://qlik.dev/tutorials/configure-a-tenant), example usage:

```bash
./tenant_configure.sh \
--client-id <CLIENT_ID> \
Expand All @@ -33,6 +36,7 @@ Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementation
```

* [Deploy a Qlik Sense application to a tenant](https://qlik.dev/tutorials/deploy-a-qlik-sense-application-to-a-tenant), example usage:

```bash
./tenant_deploy_content.sh \
--client-id <CLIENT_ID> \
Expand All @@ -49,6 +53,7 @@ Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementation
```

* Create, configure, and deploy content to a tenant - combines multiple examples into a single end to end execution, example usage:

```bash
./tenant_end_to_end.sh \
--client-id <CLIENT_ID> \
Expand All @@ -62,3 +67,9 @@ Example [Qlik CLI](https://qlik.dev/libraries-and-tools/qlik-cli) implementation
--jwt-private-key ./privatekey.pem \
--jwt-public-key ./publickey.cer
```

* [Delete a tenant](https://qlik.dev/manage/platform-operations/delete-a-tenant), example usage:

```bash
./tenant_delete.sh \
```
81 changes: 81 additions & 0 deletions qlik.dev/tutorials/platform-operations/cli-bash/tenant_delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

. constants.env

function setup_cli_contexts() {
# Setup the context for the source tenant
if ! qlik context create \
--oauth-client-id "${OAUTH_CLIENT_ID}" \
--oauth-client-secret "${OAUTH_CLIENT_SECRET}" \
--server "http://${SOURCE_TENANT_HOSTNAME}" "${SOURCE_TENANT_HOSTNAME}" > /dev/null 2>&1;
then
# Context already exists, update it.
if ! qlik context update \
--oauth-client-id "${OAUTH_CLIENT_ID}" \
--oauth-client-secret "${OAUTH_CLIENT_SECRET}" \
--server "https://${SOURCE_TENANT_HOSTNAME}" "${SOURCE_TENANT_HOSTNAME}" > /dev/null;
then
echo "ERROR: Failed to create Qlik CLI context for '${SOURCE_TENANT_HOSTNAME}'."
exit 1
fi
fi
}

function get_tenant_id() {
if ! target_tenant_id=$(qlik user me | jq -r -e '.tenantId');
then
echo "ERROR: Failed retrieved the tenant ID from tenant '${TARGET_TENANT_HOSTNAME}'."
exit 1
else
readonly target_tenant_id
fi
echo "INFO: Retrieved tenant ID from tenant '${TARGET_TENANT_HOSTNAME}'."
}

function delete_tenant () {
#To delete a tenant it first goes through a state of deactivation therefore you start by first deactivating the tenant then it eventually gets deleted.
qlik context use "${TARGET_TENANT_HOSTNAME}" > /dev/null
if ! tenant=$(qlik tenant delete "${target_tenant_id}" --json)
then
echo "ERROR: Failed to delete tenant using '${target_tenant_id}'."
exit 1
else
tenant= if ! purge_after_days=null $(--purgeAfterDays "${purge_after_days}" )
else
readonly purge_after_days="${purge_after_days}"
fi

echo "INFO: Tenant deactivated '${TARGET_TENANT_HOSTNAME}' with ID '${target_tenant_id}' and will be deleted within '${purge_after_days}'."
}

function run() {
check_required_vars

setup_cli_contexts
qlik context use "${TARGET_TENANT_HOSTNAME}" > /dev/null
get_tenant_id

if ! qlik tenant delete \

}

function parse_script_args() {
while (( "$#" )); do
case "$1" in
--help)
usage
exit 0
;;
esac
done
}
if [ -z "${SOURCE_FUNCTIONS_ONLY}" ] ; then
if ! ./check-prerequisites.sh;
then
echo "ERROR: Some prerequisites have not been installed."
exit 1
fi

parse_script_args "$@"
run "$@"
fi