func (s *Manager) GetIntegrations(ctx context.Context, id string, params model.RequestParams) (int, []interface{}, error) {
	hookResponse := s.integrationMan.InvokeHook(ctx, params)
	if hookResponse.CheckResponse() {
		if err := hookResponse.Error(); err != nil {
			return hookResponse.Status(), nil, err
		}
		return hookResponse.Status(), hookResponse.Result().([]interface{}), nil
	}
	s.lock.RLock()
	defer s.lock.RUnlock()
	result := make([]interface{}, 0)
	for _, i := range s.projectConfig.Integrations {
		if id == "*" {
			result = append(result, i)
			continue
		}
		if id == i.ID {
			result = append(result, i)
		}
	}
	if len(result) > 0 || id == "*" {
		return http.StatusOK, result, nil
	}
	return http.StatusBadRequest, nil, helpers.Logger.LogError(helpers.GetRequestID(ctx), fmt.Sprintf("Integration (%s) not found", id), nil, nil)
}
GetIntegrations returns the list of integrations from gateway
package syncman
import (
	"context"
	"encoding/base64"
	"fmt"
	"math/rand"
	"net/http"
	"time"
	"github.com/spaceuptech/helpers"
	"github.com/spaceuptech/space-cloud/gateway/config"
	"github.com/spaceuptech/space-cloud/gateway/managers/integration"
	"github.com/spaceuptech/space-cloud/gateway/model"
)
func (s *Manager) EnableIntegration(ctx context.Context, integrationConfig *config.IntegrationConfig, params model.RequestParams) (int, error) {
	hookResponse := s.integrationMan.InvokeHook(ctx, params)
	if hookResponse.CheckResponse() {
		if err := hookResponse.Error(); err != nil {
			return hookResponse.Status(), err
		}
		return hookResponse.Status(), nil
	}
	s.lock.Lock()
	defer s.lock.Unlock()
	resourceID := config.GenerateResourceID(s.clusterID, "noProject", config.ResourceIntegration, integrationConfig.ID)
	helpers.Logger.LogDebug(helpers.GetRequestID(ctx), fmt.Sprintf("Creating a new project for integration (%s)", integrationConfig.ID), nil)
	rand.Seed(time.Now().UnixNano())
	if s.runnerAddr == "" {
		return http.StatusBadRequest, helpers.Logger.LogError(helpers.GetRequestID(ctx), "Runner must be enabled for integrations to work", nil, nil)
	}
	token, err := s.adminMan.GetInternalAccessToken()
	if err != nil {
		return http.StatusInternalServerError, err
	}
	reqPayload := map[string]interface{}{"id": integrationConfig.ID, "kind": "integration"}
	if err := s.MakeHTTPRequest(ctx, "POST", fmt.Sprintf("http://%s/v1/runner/project/%s", s.runnerAddr, integrationConfig.ID), token, "", reqPayload, &map[string]interface{}{}); err != nil {
		return http.StatusInternalServerError, err
	}
	integrationKeyTemp := make([]byte, 32)
	_, _ = rand.Read(integrationKeyTemp)
	integrationKey := base64.StdEncoding.EncodeToString(integrationKeyTemp)
	reqPayload = map[string]interface{}{"id": integrationConfig.ID, "type": "env", "data": map[string]string{"PROJECT": integrationConfig.ID, "LOGIN_ID": integrationConfig.ID, "LOGIN_KEY": integrationKey}}
	if err := s.MakeHTTPRequest(ctx, "POST", fmt.Sprintf("http://%s/v1/runner/%s/secrets/%s", s.runnerAddr, integrationConfig.ID, integrationConfig.ID), token, "", reqPayload, &map[string]interface{}{}); err != nil {
		return http.StatusInternalServerError, err
	}
	integrationConfig.Key = integrationKey
	license := make(map[string]interface{})
	integrationConfig.Deployments = license["deployments"].([]interface{})
	for _, service := range integrationConfig.Deployments {
		obj := service.(map[string]interface{})
		if err := s.MakeHTTPRequest(ctx, "POST", fmt.Sprintf("http://%s/v1/runner/%s/services/%s/%s", s.runnerAddr, integrationConfig.ID, obj["id"], obj["version"]), token, "", obj, &map[string]interface{}{}); err != nil {
			return http.StatusInternalServerError, err
		}
	}
	key := make([]byte, 32)
	if _, err := rand.Read(key); err != nil {
		return http.StatusInternalServerError, helpers.Logger.LogError(helpers.GetRequestID(ctx), "Unable to create new aes key for integration", nil, nil)
	}
	integrations := make(config.Integrations)
	var proj *config.ProjectConfig
	if _, p := s.projectConfig.Integrations.Get(integrationConfig.ID); !p {
		proj = &config.ProjectConfig{
			ID:                 integrationConfig.ID,
			Name:               integrationConfig.Name,
			SecretSource:       integrationConfig.SecretSource,
			ContextTimeGraphQL: 20,
			AESKey:             base64.StdEncoding.EncodeToString(key),
			IsIntegration:      true,
		}
		integrations[resourceID] = integrationConfig
	} else {
		integrations = s.projectConfig.Integrations
		integrations[resourceID] = integrationConfig
	}
	if err := s.integrationMan.SetIntegrations(integrations); err != nil {
		return http.StatusUpgradeRequired, err
	}
	s.adminMan.SetIntegrationConfig(integrations)
	s.projectConfig.Integrations = integrations
	if err := s.store.SetResource(ctx, resourceID, integrationConfig); err != nil {
		return http.StatusInternalServerError, err
	}
	if proj != nil {
		s.projectConfig.Projects[proj.ID] = &config.Project{ProjectConfig: proj}
		if err := s.modules.SetProjectConfig(ctx, proj); err != nil {
			return http.StatusInternalServerError, helpers.Logger.LogError(helpers.GetRequestID(ctx), "Unable to create new project for integration", nil, nil)
		}
		rID := config.GenerateResourceID(s.clusterID, proj.ID, config.ResourceProject, proj.ID)
		if err := s.store.SetResource(ctx, rID, proj); err != nil {
			return http.StatusInternalServerError, err
		}
	}
	return http.StatusOK, nil
}
func (s *Manager) RemoveIntegration(ctx context.Context, id string, params model.RequestParams) (int, error) {
	hookResponse := s.integrationMan.InvokeHook(ctx, params)
	if hookResponse.CheckResponse() {
		if err := hookResponse.Error(); err != nil {
			return hookResponse.Status(), err
		}
		return hookResponse.Status(), nil
	}
	s.lock.Lock()
	defer s.lock.Unlock()
	token, err := s.adminMan.GetInternalAccessToken()
	if err != nil {
		return http.StatusInternalServerError, err
	}
	if err := s.MakeHTTPRequest(ctx, http.MethodDelete, fmt.Sprintf("http://%s/v1/runner/%s", s.runnerAddr, id), token, "", &map[string]interface{}{}, &map[string]interface{}{}); err != nil {
		return http.StatusInternalServerError, err
	}
	projectResourceID := config.GenerateResourceID(s.clusterID, id, config.ResourceProject, id)
	delete(s.projectConfig.Projects, projectResourceID)
	integrationResourceID := config.GenerateResourceID(s.clusterID, "noProject", config.ResourceIntegration, id)
	delete(s.projectConfig.Integrations, integrationResourceID)
	for _, hook := range s.projectConfig.IntegrationHooks {
		if hook.IntegrationID == id {
			resourceID := config.GenerateResourceID(s.clusterID, "noProject", config.ResourceIntegrationHook, hook.ID)
			delete(s.projectConfig.IntegrationHooks, resourceID)
			if err := s.store.DeleteResource(ctx, resourceID); err != nil {
				return http.StatusInternalServerError, err
			}
		}
	}
	s.modules.Delete(id)
	_ = s.integrationMan.SetConfig(s.projectConfig.Integrations, s.projectConfig.IntegrationHooks)
	if err := s.store.DeleteProject(ctx, id); err != nil {
		return http.StatusInternalServerError, err
	}
	if err := s.store.DeleteResource(ctx, integrationResourceID); err != nil {
		return http.StatusInternalServerError, err
	}
	return http.StatusOK, nil
}