in frontend/src/model.tsx [101:137]
function CreateCluster(
clusterName: string,
clusterConfig: string,
region: string,
selectedRegion: string,
dryrun = false,
successCallback?: Callback,
errorCallback?: Callback,
) {
var url = 'api?path=/v3/clusters'
url += dryrun ? '&dryrun=true' : ''
url += region ? `®ion=${region}` : ''
var body = {
clusterName: clusterName,
clusterConfiguration: mapAndApplyTags(clusterConfig),
}
request('post', url, body)
.then((response: any) => {
if (response.status === 202) {
if (!dryrun && region === selectedRegion) {
updateState(['clusters', 'index', clusterName], (existing: any) => {
return {...existing, ...response.data}
})
}
successCallback && successCallback(response.data)
} else {
console.log(response)
notify(`Error (${clusterName}): ${response.data.message}`, 'error')
}
})
.catch((error: any) => {
if (error.response) {
errorCallback && errorCallback(error.response.data)
console.log(error.response.data)
}
})
}