Repository: amp-labs/connectors
Pull request #1474 (2025-03-12 16:23:05)

[CON-1567] feat: Add Clickup ListMetadata
# Testing
<img width="656" alt="image" src="https://github.com/user-attachments/assets/ed1d554f-c580-4640-8eef-7cf66498f94c" />



Patch:
diff --git a/providers/clickup/connector.go b/providers/clickup/connector.go
new file mode 100644
index 00000000..3943b29c
--- /dev/null
+++ b/providers/clickup/connector.go
@@ -0,0 +1,35 @@
+package clickup
+
+import (
+	"github.com/amp-labs/connectors/common"
+	"github.com/amp-labs/connectors/internal/components"
+	"github.com/amp-labs/connectors/internal/components/schema"
+	"github.com/amp-labs/connectors/providers"
+	"github.com/amp-labs/connectors/providers/clickup/metadata"
+)
+
+type Connector struct {
+	// Basic connector
+	*components.Connector
+
+	// Require authenticated client
+	common.RequireAuthenticatedClient
+
+	// supported operations
+	components.SchemaProvider
+}
+
+func NewConnector(params common.Parameters) (*Connector, error) {
+	// Create base connector with provider info
+	return components.Initialize(providers.ClickUp, params, constructor)
+}
+
+//nolint:funlen
+func constructor(base *components.Connector) (*Connector, error) {
+	connector := &Connector{Connector: base}
+
+	// Set the metadata provider for the connector
+	connector.SchemaProvider = schema.NewOpenAPISchemaProvider(connector.ProviderContext.Module(), metadata.Schemas)
+
+	return connector, nil
+}
diff --git a/providers/clickup/metadata/schemas.json b/providers/clickup/metadata/schemas.json
new file mode 100644
index 00000000..19248dcd
--- /dev/null
+++ b/providers/clickup/metadata/schemas.json
@@ -0,0 +1,22 @@
+{
+  "modules": {
+    "root": {
+      "id": "",
+      "path": "",
+      "objects": {
+        "team": {
+          "displayName": "Team",
+          "path": "team",
+          "responseKey": "teams",
+          "fields": {
+            "id": "id",
+            "name": "name",
+            "color": "color",
+            "avatar": "avatar",
+            "members": "members"
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/providers/clickup/metadata/scraping.go b/providers/clickup/metadata/scraping.go
new file mode 100644
index 00000000..86cebe92
--- /dev/null
+++ b/providers/clickup/metadata/scraping.go
@@ -0,0 +1,19 @@
+package metadata
+
+import (
+	_ "embed"
+
+	"github.com/amp-labs/connectors/internal/staticschema"
+	"github.com/amp-labs/connectors/tools/fileconv"
+	"github.com/amp-labs/connectors/tools/scrapper"
+)
+
+// nolint:gochecknoglobals
+var (
+	//go:embed schemas.json
+	schemaContent []byte
+	FileManager   = scrapper.NewMetadataFileManager[staticschema.FieldMetadataMapV1](
+		schemaContent, fileconv.NewSiblingFileLocator())
+
+	Schemas = FileManager.MustLoadSchemas()
+)


Test patch:
diff --git a/test/clickup/connector.go b/test/clickup/connector.go
new file mode 100644
index 00000000..87e4603b
--- /dev/null
+++ b/test/clickup/connector.go
@@ -0,0 +1,56 @@
+package clickup
+
+import (
+	"context"
+	"net/http"
+
+	"github.com/amp-labs/connectors/common"
+	"github.com/amp-labs/connectors/common/scanning/credscanning"
+	"github.com/amp-labs/connectors/providers"
+	"github.com/amp-labs/connectors/providers/clickup"
+	"github.com/amp-labs/connectors/test/utils"
+	"golang.org/x/oauth2"
+)
+
+func GetClickupConnector(ctx context.Context) *clickup.Connector {
+	filePath := credscanning.LoadPath(providers.ClickUp)
+	reader := utils.MustCreateProvCredJSON(filePath, true, false)
+
+	options := []common.OAuthOption{
+		common.WithOAuthClient(http.DefaultClient),
+		common.WithOAuthConfig(getConfig(reader)),
+		common.WithOAuthToken(&oauth2.Token{
+			AccessToken:  reader.Get(credscanning.Fields.AccessToken),
+			RefreshToken: reader.Get(credscanning.Fields.RefreshToken),
+		}),
+	}
+
+	client, err := common.NewOAuthHTTPClient(ctx, options...)
+	if err != nil {
+		utils.Fail(err.Error())
+	}
+
+	conn, err := clickup.NewConnector(
+		common.Parameters{
+			AuthenticatedClient: client,
+		},
+	)
+	if err != nil {
+		utils.Fail("error creating clickup connector", "error", err)
+	}
+
+	return conn
+}
+
+func getConfig(reader *credscanning.ProviderCredentials) *oauth2.Config {
+	return &oauth2.Config{
+		ClientID:     reader.Get(credscanning.Fields.ClientId),
+		ClientSecret: reader.Get(credscanning.Fields.ClientSecret),
+		Endpoint: oauth2.Endpoint{
+			AuthURL:   "https://app.clickup.com/api",
+			TokenURL:  "https://api.clickup.com/api/v2/oauth/token",
+			AuthStyle: oauth2.AuthStyleInHeader,
+		},
+		RedirectURL: "http://localhost:8080/callbacks/v1/oauth",
+	}
+}
diff --git a/test/clickup/metadata/main.go b/test/clickup/metadata/main.go
new file mode 100644
index 00000000..55390dce
--- /dev/null
+++ b/test/clickup/metadata/main.go
@@ -0,0 +1,25 @@
+package main
+
+import (
+	"context"
+	"log"
+	"os"
+
+	"github.com/amp-labs/connectors/test/clickup"
+	"github.com/amp-labs/connectors/test/utils"
+)
+
+func main() {
+	ctx := context.Background()
+
+	conn := clickup.GetClickupConnector(ctx) // nolint
+
+	// nolint
+	m, err := conn.ListObjectMetadata(ctx, []string{"team"})
+
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	utils.DumpJSON(m, os.Stdout)
+}