Skip to main content

controller.go

controller.go - Overview

  1. Overview This file defines the Controller struct and its methods for managing integrations. It provides functionalities for listing, retrieving, installing, and uninstalling integrations, as well as retrieving pipelines and dashboards associated with installed integrations.

  2. Detailed Documentation

Controller

  • Purpose: The Controller struct is responsible for handling integration-related operations. It holds a reference to the Manager which performs the core logic.
  • Fields:
    • mgr: A pointer to the Manager instance.

NewController

  • Purpose: Creates a new Controller instance.
  • Parameters:
    • sqlStore (sqlstore.SQLStore): The SQL store instance.
  • Returns:
    • *Controller: A pointer to the newly created Controller instance.
    • error: An error if the Manager cannot be created.

IntegrationsListResponse

  • Purpose: Represents the response structure for listing integrations.
  • Fields:
    • Integrations ([]IntegrationsListItem): A slice of IntegrationsListItem representing the integrations.

(c *Controller) ListIntegrations

  • Purpose: Lists integrations based on provided filters.
  • Parameters:
    • ctx (context.Context): The context.
    • params (map[string]string): A map of filter parameters (e.g., is_installed).
  • Returns:
    • *IntegrationsListResponse: A pointer to the IntegrationsListResponse containing the list of integrations.
    • *model.ApiError: An API error if any occurred.

(c *Controller) GetIntegration

  • Purpose: Retrieves a specific integration by its ID.
  • Parameters:
    • ctx (context.Context): The context.
    • integrationId (string): The ID of the integration to retrieve.
  • Returns:
    • *Integration: A pointer to the Integration object.
    • *model.ApiError: An API error if any occurred.

(c *Controller) IsIntegrationInstalled

  • Purpose: Checks if an integration is installed.
  • Parameters:
    • ctx (context.Context): The context.
    • integrationId (string): The ID of the integration to check.
  • Returns:
    • bool: true if the integration is installed, false otherwise.
    • *model.ApiError: An API error if any occurred.

(c *Controller) GetIntegrationConnectionTests

  • Purpose: Retrieves connection tests for a specific integration.
  • Parameters:
    • ctx (context.Context): The context.
    • integrationId (string): The ID of the integration.
  • Returns:
    • *IntegrationConnectionTests: A pointer to the IntegrationConnectionTests object.
    • *model.ApiError: An API error if any occurred.

InstallIntegrationRequest

  • Purpose: Represents the request structure for installing an integration.
  • Fields:
    • IntegrationId (string): The ID of the integration to install.
    • Config (map[string]interface{}): The configuration for the integration.

(c *Controller) Install

  • Purpose: Installs an integration.
  • Parameters:
    • ctx (context.Context): The context.
    • req (*InstallIntegrationRequest): The install request containing the integration ID and configuration.
  • Returns:
    • *IntegrationsListItem: A pointer to the IntegrationsListItem representing the installed integration.
    • *model.ApiError: An API error if any occurred.

UninstallIntegrationRequest

  • Purpose: Represents the request structure for uninstalling an integration.
  • Fields:
    • IntegrationId (string): The ID of the integration to uninstall.

(c *Controller) Uninstall

  • Purpose: Uninstalls an integration.
  • Parameters:
    • ctx (context.Context): The context.
    • req (*UninstallIntegrationRequest): The uninstall request containing the integration ID.
  • Returns:
    • *model.ApiError: An API error if any occurred.

(c *Controller) GetPipelinesForInstalledIntegrations

  • Purpose: Retrieves pipelines for installed integrations.
  • Parameters:
    • ctx (context.Context): The context.
  • Returns:
    • []pipelinetypes.GettablePipeline: A slice of GettablePipeline objects.
    • *model.ApiError: An API error if any occurred.

(c *Controller) GetDashboardsForInstalledIntegrations

  • Purpose: Retrieves dashboards for installed integrations.
  • Parameters:
    • ctx (context.Context): The context.
  • Returns:
    • []types.Dashboard: A slice of Dashboard objects.
    • *model.ApiError: An API error if any occurred.

(c *Controller) GetInstalledIntegrationDashboardById

  • Purpose: Retrieves a specific installed integration dashboard by its ID.
  • Parameters:
    • ctx (context.Context): The context.
    • dashboardUuid (string): The UUID of the dashboard.
  • Returns:
    • *types.Dashboard: A pointer to the Dashboard object.
    • *model.ApiError: An API error if any occurred.
  1. Code Examples None

  2. Clarity and Accuracy The documentation is based solely on the code provided.

Include in Getting Started: NO