Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Tim Rice
onetrust_updatescores
Commits
eea03e66
Commit
eea03e66
authored
7 months ago
by
Tim Rice
Browse files
Options
Download
Email Patches
Plain Diff
Add new file
parent
695311b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
update_vendor_score
update_vendor_score
+46
-0
No files found.
update_vendor_score
0 → 100644
View file @
eea03e66
#!/bin/bash
# Fetch the token
./get_token
TOKEN
=
$(
<.token
)
# Check if both vendor ID and letter grade are provided
if
[
$#
-ne
2
]
;
then
echo
"Usage:
$0
<vendor_id> <lettergrade>"
exit
1
fi
id
=
$1
letterscore
=
$(
echo
"
$2
"
|
tr
'[:lower:]'
'[:upper:]'
)
#Map letter grades to vendor score IDs. Each dropdown value in the vendorRating field has a unique id
declare
-A
score_map
=(
[
"A"
]=
"00c83b87-cff1-4e81-9c19-a66984ec5077"
[
"B"
]=
"2dde940a-3b05-4f15-b31e-81e4ecba617c"
[
"C"
]=
"eefbb260-e2bc-4be5-b3d2-1ef0e9902d1c"
[
"D"
]=
"ca270274-3085-432a-919b-9f101881c12b"
[
"F"
]=
"3defc5cc-3afb-424c-a95b-76071cc515bf"
)
vendorscoreid
=
${
score_map
[
$letterscore
]
}
if
[
-z
"
$vendorscoreid
"
]
;
then
echo
"Invalid letter grade:
$letterscore
"
exit
1
fi
#updating the "Vendor Score" attribute for the vendor
curl
-s
--request
PUT
\
--url
"https://app.onetrust.com/api/inventory/v2/inventories/vendors/
$id
"
\
--header
'accept: application/json'
\
--header
'content-type: application/json'
\
--header
"authorization: Bearer
$TOKEN
"
\
--data
"{
\"
vendorRating
\"
: [
{
\"
id
\"
:
\"
$vendorscoreid
\"
,
\"
value
\"
:
\"
$letterscore
\"
,
\"
valueKey
\"
:
\"
VendorsVendorRating
$letterscore
\"
}
]
}"
>
/dev/null
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment