Files
threshold/internal/tests/cli/boundary/_aliases.bash
T
Irena Rindos ba21e076bb cli(aliases): Support aliases for connect and targets in the CLI (#4356)
* cli(aliases): Support aliases for boundary connect and boundary targets CLI
2024-02-29 15:52:27 -08:00

70 lines
1.5 KiB
Bash

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
load _authorized_actions
function create_target_alias() {
local value=$1
local destid=$2
boundary aliases create target \
-value $value \
-destination-id $destid \
-format json
}
function read_alias(){
boundary aliases read -id $1 -format json
}
function delete_alias(){
boundary aliases delete -id $1 -format json
}
function list_alias(){
boundary aliases list -format json
}
function update_target_alias_value(){
local aid=$1
local value=$2
boundary aliases update target \
-id $aid \
-value $value \
-format json
}
function update_target_alias_host_id(){
local aid=$1
local hostid=$2
boundary aliases update target \
-id $aid \
-authorize-session-host-id $hostid \
-format json
}
function update_target_alias_remove_destination_id(){
local aid=$1
boundary aliases update target \
-id $aid \
-destination-id null \
-format json
}
function update_target_alias_destination_id(){
local aid=$1
local destid=$2
boundary aliases update target \
-id $aid \
-destination-id $destid \
-format json
}
function alias_id_from_target_alias(){
local alias=$1
strip $(list_alias | jq -c ".items[] | select(.value | contains(\"$alias\")) | .[\"id\"]")
}
function host_id_from_alias_id(){
local aid=$1
strip $(read_alias $aid | jq -c ".item | .attributes | .authorize_session_arguments | .host_id")
}