in internal/client/connections/connectors.go [1029:1088]
func Export(folder string) (err error) {
apiclient.SetExportToFile(folder)
apiclient.ClientPrintHttpResponse.Set(false)
defer apiclient.ClientPrintHttpResponse.Set(apiclient.GetCmdPrintHttpResponseSetting())
pageToken := ""
lconnections := listconnections{}
for {
l := listconnections{}
respBody, err := List(maxPageSize, pageToken, "", "")
if err != nil {
return fmt.Errorf("failed to fetch Integrations: %w", err)
}
err = json.Unmarshal(respBody, &l)
if err != nil {
return fmt.Errorf("failed to unmarshall: %w", err)
}
lconnections.Connections = append(lconnections.Connections, l.Connections...)
pageToken = l.NextPageToken
if l.NextPageToken == "" {
break
}
}
// no connections where found
if len(lconnections.Connections) == 0 {
return nil
}
for _, lconnection := range lconnections.Connections {
lconnection.ConnectorDetails = new(connectorDetails)
lconnection.ConnectorDetails.Name = getConnectorName(*lconnection.ConnectorVersion)
if lconnection.ConnectorDetails.Provider != "customconnector" {
lconnection.ConnectorDetails.Version = new(int)
*lconnection.ConnectorDetails.Version = getConnectorVersion(*lconnection.ConnectorVersion)
} else {
lconnection.ConnectorDetails.VersionId = new(string)
*lconnection.ConnectorDetails.VersionId = getConnectorVersionId(*lconnection.ConnectorVersion)
}
lconnection.ConnectorVersion = nil
fileName := getConnectionName(*lconnection.Name) + ".json"
lconnection.Name = nil
connectionPayload, err := json.Marshal(lconnection)
if err != nil {
return err
}
if err = apiclient.WriteByteArrayToFile(
path.Join(apiclient.GetExportToFile(), fileName),
false,
connectionPayload); err != nil {
clilog.Error.Println(err)
return err
}
clilog.Info.Printf("Downloaded %s\n", fileName)
}
return nil
}