func GetConnectionsWithRegion()

in internal/client/integrations/integrations.go [900:944]


func GetConnectionsWithRegion(integration []byte) (connections []integrationConnection, err error) {
	iversion := integrationVersion{}

	err = json.Unmarshal(integration, &iversion)
	if err != nil {
		return connections, err
	}

	for _, taskConfig := range iversion.TaskConfigs {
		if taskConfig.Task == "GenericConnectorTask" {
			connectionParams := taskConfig.Parameters["config"]
			if connectionParams.Key == "config" && connectionParams.Value.JsonValue != nil {
				newConnection := integrationConnection{}
				newConnection.Name = getConnectionName(*connectionParams.Value.JsonValue)
				newConnection.Region = getConnectionRegion(*connectionParams.Value.JsonValue)
				newConnection.Version = getConnectionVersion(*connectionParams.Value.JsonValue)
				newConnection.CustomConnection = false
				connections = append(connections, newConnection)
			}
			if _, ok := taskConfig.Parameters["connectionName"]; ok {
				// check custom connection
				if isCustomConnection(taskConfig.Parameters["connectionVersion"]) {
					newCustomConnection := getIntegrationCustomConnection(taskConfig.Parameters["connectionVersion"])
					connections = append(connections, newCustomConnection)
					newConnection := getIntegrationConnection(taskConfig.Parameters["connectionName"],
						taskConfig.Parameters["connectionVersion"], iversion.IntegrationConfigParameters)
					connections = append(connections, newConnection)
				} else {
					newConnection := getIntegrationConnection(taskConfig.Parameters["connectionName"],
						taskConfig.Parameters["connectionVersion"], iversion.IntegrationConfigParameters)
					connections = append(connections, newConnection)
				}
			}
		}
	}
	for _, triggerConfig := range iversion.TriggerConfigs {
		if triggerConfig.TriggerType == "INTEGRATION_CONNECTOR_TRIGGER" {
			newConnection := integrationConnection{}
			newConnection.Name = triggerConfig.Properties["Connection name"]
			newConnection.Region = triggerConfig.Properties["Region"]
			connections = append(connections, newConnection)
		}
	}
	return connections, err
}