-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-fusion-objects.ps1
150 lines (124 loc) · 4.32 KB
/
export-fusion-objects.ps1
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<#
.SYNOPSIS
The purpose of this script is to export Lucidworks Fusion objects.
.DESCRIPTION
This script connects to the Fusion API and downloads the object (pipeline,
data source, etc.) as a ZIP file. The ZIP file is extracted and the objects.json
contained therein is left intact on the file system.
.PARAMETER env
The environment (DEV, QA, PROD) which to connect and download the configured
objects.
.NOTES
File Name: export-fusion-objects.ps1
Author: Chris Cook, Onix - [email protected]
Released: 2019-10-25
Updated: 2019-10-27 Added this comment block in the header
.EXAMPLE
Run the export-fusion-objects script to dump the objects in development:
export-fusion-objects -env DEV
.LINK
https://github.com/onix-ccook/Fusion-Asset-Management-for-Windows
#requires -version 2
#>
[CmdletBinding()]
Param
(
[parameter(
mandatory=$true,
HelpMessage="Which Environment to export? DEV, QA or PROD"
)]
[ValidateSet('DEV','QA','PROD')]
[string] $env
)
#----------------[ Declarations ]------------------------------------------------------
$USER = "admin"
$PASS = "pasword123"
$PROJECT_HOME = "C:\fusion\dev"
$VERSION = "422"
$auth = "${USER}:${PASS}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($auth)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ "Authorization" = $basicAuthValue }
# Dev
$DEV_VERSION = $VERSION
$DEV_HOSTNAME = "search-dev.company.com"
$DEV_DATASOURCES = "site1_WEB","file1_SMB"
$DEV_INDEX_PIPELINES = ""
$DEV_QUERY_PIPELINES = "crawlDB","intranet_suggest_v1"
$DEV_QUERY_PROFILES = "intranet","intranet_suggest"
$DEV_SPARK_JOBS = "Site_Search_suggestions"
# QA
$QA_VERSION = $VERSION
$QA_HOSTNAME = ""
$QA_DATASOURCES = ""
$QA_INDEX_PIPELINES = ""
$QA_QUERY_PIPELINES = ""
$QA_QUERY_PROFILES = ""
$QA_SPARK_JOBS = ""
# Prod
$PROD_VERSION = $VERSION
$PROD_HOSTNAME = ""
$PROD_DATASOURCES = ""
$PROD_INDEX_PIPELINES = ""
$PROD_QUERY_PIPELINES = ""
$PROD_QUERY_PROFILES = ""
$PROD_SPARK_JOBS = ""
#----------------[ Functions ]---------------------------------------------------------
function getOBJ($url, $outfile, $dumpdir) {
New-Item -ItemType Directory -Force -Path $dumpdir
Invoke-WebRequest -uri $url -Headers $headers -OutFile $outfile
Expand-Archive -Force -LiteralPath $outfile -DestinationPath $dumpdir
}
function run($ENV) {
$HN = Get-Variable -ValueOnly -Name "${ENV}_HOSTNAME"
$VER = Get-Variable -ValueOnly -Name "${ENV}_VERSION"
$DS = Get-Variable -ValueOnly -Name "${ENV}_DATASOURCES"
$IPL = Get-Variable -ValueOnly -Name "${ENV}_INDEX_PIPELINES"
$QPL = Get-Variable -ValueOnly -Name "${ENV}_QUERY_PIPELINES"
$QPR = Get-Variable -ValueOnly -Name "${ENV}_QUERY_PROFILES"
$JOB = Get-Variable -ValueOnly -Name "${ENV}_SPARK_JOBS"
if ($HN -eq '') { return }
# DATASOURCES
foreach ($a in $DS) {
if ($a -eq '') { break }
$dump_dir="$PROJECT_HOME\$ENV\DS-$a"
$out="$dump_dir\$a-$VER.zip"
$url="http://${HN}:8764/api/apollo/objects/export?datasource.ids=$a"
getOBJ $url $out $dump_dir
}
# INDEX_PIPELINES
foreach ($a in $IPL) {
if ($a -eq '') { break }
$dump_dir="$PROJECT_HOME\$ENV\IPL-$a"
$out="$dump_dir\$a-$VER.zip"
$url="http://${HN}:8764/api/apollo/objects/export?index-pipeline.ids=$a"
getOBJ $url $out $dump_dir
}
# QUERY_PIPELINES
foreach ($a in $QPL) {
if ($a -eq '') { break }
$dump_dir="$PROJECT_HOME\$ENV\QPL-$a"
$out="$dump_dir\$a-$VER.zip"
$url="http://${HN}:8764/api/apollo/objects/export?query-pipeline.ids=$a"
getOBJ $url $out $dump_dir
}
# QUERY_PROFILES
foreach ($a in $QPR) {
if ($a -eq '') { break }
$dump_dir="$PROJECT_HOME\$ENV\QPR-$a"
$out="$dump_dir\$a-$VER.zip"
$url="http://${HN}:8764/api/apollo/objects/export?query-profile.ids=$a"
getOBJ $url $out $dump_dir
}
# SPARK_JOBS
foreach ($a in $JOB) {
if ($a -eq '') { break }
$dump_dir="$PROJECT_HOME\$ENV\JOB-$a"
$out="$dump_dir\$a-$VER.zip"
$url="http://${HN}:8764/api/apollo/objects/export?spark.ids=$a"
getOBJ $url $out $dump_dir
}
}
#----------------[ Main Execution ]----------------------------------------------------
run $env