-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdoapic-prod.bat
88 lines (75 loc) · 2.84 KB
/
doapic-prod.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
echo off
setlocal
set server=%1
set user=steve
set password=Passw0rd
set user_file=user-steve.txt
set porg_name=steveorg
set api_file=findbrancha.yaml
set prod_file=brancha_prod.yaml
apic login --server %server% --username %user% --password %password% --realm provider/default-idp-2
timeout /t 3 /nobreak > NUL
echo Current draft apis:
apic draft-apis:list-all --server %server% --org %porg_name%
echo Current draft products:
apic draft-products:list-all --server %server% --org %porg_name%
echo :
echo create new draft prod
apic draft-products:create --server %server% --org %porg_name% brancha_prod.yaml
echo :
echo publish same draft prod
echo :
rem capture product url for use in replace map
set ACMD=apic products:publish --server %server% --org %porg_name% --catalog sandbox brancha_prod.yaml
for /f "tokens=4 delims= " %%a in ('%ACMD%') do set gURL=%%a
set product_url=product_url: %gURL%
echo %product_url%>prodmap.txt
echo plans:>>prodmap.txt
echo - source: default>>prodmap.txt
echo target: default>>prodmap.txt
echo Published product list
apic products:list-all --server %server% --org %porg_name% --catalog sandbox --scope catalog
echo :
rem create new api and prod yaml locally
rem first make sure file doesn't exist
del findbrancha2.yaml
del brancha_prod2.yaml
for /F "delims=" %%i in (%api_file%) do (
echo "%%i" | findstr /C:"version: 1">nul && (
echo version: 2.0.0 >> findbrancha2.yaml
) || (
echo.%%i >> findbrancha2.yaml
)
)
for /F "delims=" %%i in (%prod_file%) do (
echo "%%i" | findstr /C:"version: 1">nul && (
echo version: 2.0.0 >> brancha_prod2.yaml
) || (
echo "%%i" | findstr /C:"findbrancha.yaml">nul && (
echo $ref: findbrancha2.yaml>>brancha_prod2.yaml )
) || (
echo.%%i >> brancha_prod2.yaml
)
)
echo stage new version of product
apic products:publish --server %server% --org %porg_name% --catalog sandbox --stage brancha_prod2.yaml
timeout /t 2 /nobreak > NUL
echo :
echo list all products in catalog - note staged
apic products:list-all --server %server% --org %porg_name% --catalog sandbox --scope catalog
echo :
echo replace published with staged product
apic products:replace --server %server% --org %porg_name% --scope catalog --catalog sandbox findbrancha:2.0.0 prodmap.txt
timeout /t 1 /nobreak > NUL
echo :
echo list all products in catalog - note state
apic products:list-all --server %server% --org %porg_name% --catalog sandbox --scope catalog
echo :
echo delete retired product
apic products:delete --server %server% --org %porg_name% --scope catalog --catalog sandbox findbrancha:1.0.0
echo :
echo list products
apic products:list-all --server %server% --org %porg_name% --catalog sandbox --scope catalog
echo :
echo work done
apic logout --server %server%