Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
B
bs-utils-tools
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
bs-utils-tools
Commits
b7763153
Commit
b7763153
authored
Feb 03, 2025
by
Krit Punpreuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Pipeline
#1531
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
backup_bsjob.sh
backup_bsjob.sh
+31
-0
No files found.
backup_bsjob.sh
0 → 100644
View file @
b7763153
#!/bin/bash
# First API endpoint - returns an array of strings
API_URL
=
"https://mecas02.igridproject.info/bsapi/jobs"
# Second API endpoint - combine each element from the first API
SECOND_API_URL
=
"https://mecas02.igridproject.info/bsapi/jobs/"
# Directory to store the response files
SAVE_DIR
=
"save_jobs"
# Check if the directory exists; if not, create it
if
[
!
-d
"
$SAVE_DIR
"
]
;
then
echo
"Directory '
$SAVE_DIR
' does not exist. Creating..."
mkdir
"
$SAVE_DIR
"
fi
# Fetch data from the first API
response
=
$(
curl
-s
"
$API_URL
"
)
# Use jq to parse the response and extract the array of strings
array_of_strings
=
$(
echo
"
$response
"
| jq
-r
'.[]'
)
for
item
in
$array_of_strings
;
do
echo
"Processing job:
$item
"
second_response
=
$(
curl
-s
"
$SECOND_API_URL$item
"
)
echo
"
$second_response
"
>
"
${
SAVE_DIR
}
/
${
item
}
.json"
echo
"
${
SAVE_DIR
}
/
${
item
}
.json save"
done
\ No newline at end of file
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