{
  "id": "xP8zxPGFucxcxmYM",
  "name": "Replicated Support Bundles \u2192 Snowflake",
  "tags": [
    {
      "id": "GP5LfI2vYnciHWqB",
      "name": "replicated",
      "createdAt": "2025-06-07T11:06:10.915Z",
      "updatedAt": "2025-06-07T11:06:10.915Z"
    },
    {
      "id": "17",
      "name": "snowflake",
      "createdAt": "2023-09-18T17:05:02.756Z",
      "updatedAt": "2023-09-18T17:05:02.756Z"
    }
  ],
  "nodes": [
    {
      "id": "6f313b0f-aeed-44b2-bfa4-735a212ef551",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        96
      ],
      "parameters": {
        "width": 480,
        "height": 848,
        "content": "## Replicated Support Bundles \u2192 Snowflake\n\n### How it works\n\n1. The workflow starts with a weekly schedule trigger.\n2. It clears the Snowflake table for support bundles.\n3. Support bundles data is retrieved via an HTTP request.\n4. The retrieved data is split and manually mapped.\n5. The mapped data is updated in the Snowflake database.\n\n### Setup steps\n\n- [ ] Ensure Snowflake database credentials are correctly set up.\n- [ ] Ensure Replicated API credentials are configured for the HTTP request.\n- [ ] Schedule the trigger for the desired interval.\n\n### Customization\n\nYou can adjust the scheduling frequency to match your data processing needs."
      },
      "typeVersion": 1
    },
    {
      "id": "903b258f-f88e-4d56-876c-69b58957a651",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 688,
        "height": 272,
        "content": "## Initialize weekly process\n\nStarts the weekly data flow by triggering and resetting the Snowflake table."
      },
      "typeVersion": 1
    },
    {
      "id": "63e63f99-a1bb-4672-857d-7c61b923c771",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        96
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 304,
        "content": "## Retrieve and split data\n\nFetches support bundles via HTTP request and splits the data for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "480531d7-7c68-4ada-81f1-bbfc31112e76",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 272,
        "content": "## Map and update data\n\nMaps fields and updates the processed data in Snowflake."
      },
      "typeVersion": 1
    },
    {
      "id": "5a2b3c2a-c8c6-406c-b46a-ee6ab7657013",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        608
      ],
      "parameters": {
        "color": 7,
        "width": 240,
        "height": 336,
        "content": "## Prepare Snowflake table\n\nPrepares the Snowflake database by creating necessary tables for support bundles."
      },
      "typeVersion": 1
    },
    {
      "id": "ac10b61d-46bd-4c54-b31d-d3d5bcb5dbc4",
      "name": "Split Support Bundles",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1056,
        224
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "bundles"
      },
      "typeVersion": 1
    },
    {
      "id": "0148b94a-7bf7-43d2-851f-1d94fe706213",
      "name": "Build Support Bundle Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1360,
        224
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "supportbundle_id",
              "stringValue": "={{ $json.id }}"
            },
            {
              "name": "supportbundle_name",
              "stringValue": "={{ $json.name }}"
            },
            {
              "name": "supportbundle_uploaded_date",
              "stringValue": "={{ $json.uploadedAt }}"
            },
            {
              "name": "supportbundle_created_date",
              "stringValue": "={{ $json.collectedAt }}"
            },
            {
              "name": "supportbundle_source",
              "stringValue": "={{ $json.source }}"
            },
            {
              "name": "supportbundle_customer_id",
              "stringValue": "={{ $json.customerId }}"
            },
            {
              "name": "supportbundle_instance_id",
              "stringValue": "={{ $json.instanceId }}"
            },
            {
              "name": "supportbundle_size",
              "type": "numberValue",
              "numberValue": "={{ $json.size }}"
            },
            {
              "name": "supportbundle_viewed",
              "type": "booleanValue",
              "booleanValue": "={{ $json.viewed }}"
            }
          ]
        },
        "include": "none",
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "ea4003e7-ac7f-453d-a40f-7f1b7d45599b",
      "name": "Purge Support Bundles Table",
      "type": "n8n-nodes-base.snowflake",
      "position": [
        544,
        224
      ],
      "parameters": {
        "query": "TRUNCATE TABLE COMMON.REPLICATED_SUPPORTBUNDLES;",
        "operation": "executeQuery"
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "1f79aded-d5d7-4726-878c-f3110568d307",
      "name": "Create Support Bundles Table",
      "type": "n8n-nodes-base.snowflake",
      "position": [
        144,
        784
      ],
      "parameters": {
        "query": "CREATE OR REPLACE TABLE COMMON.REPLICATED_SUPPORTBUNDLES (\n    supportbundle_id STRING NOT NULL,\n    supportbundle_name STRING,\n    supportbundle_uploaded_date TIMESTAMP_NTZ,\n    supportbundle_created_date TIMESTAMP_NTZ,\n    supportbundle_source STRING,\n    supportbundle_customer_id STRING,\n    supportbundle_instance_id STRING,\n    supportbundle_size NUMBER,\n    supportbundle_viewed BOOLEAN\n);",
        "operation": "executeQuery"
      },
      "typeVersion": 1
    },
    {
      "id": "a2a0c313-fd79-441d-a0a4-f7b76289c7b0",
      "name": "Update Replicated Bundles",
      "type": "n8n-nodes-base.snowflake",
      "position": [
        1904,
        224
      ],
      "parameters": {
        "table": "COMMON.REPLICATED_SUPPORTBUNDLES",
        "columns": "SUPPORTBUNDLE_ID,SUPPORTBUNDLE_NAME,SUPPORTBUNDLE_UPLOADED_DATE,SUPPORTBUNDLE_CREATED_DATE,SUPPORTBUNDLE_SOURCE,SUPPORTBUNDLE_CUSTOMER_ID,SUPPORTBUNDLE_INSTANCE_ID,SUPPORTBUNDLE_SIZE,SUPPORTBUNDLE_VIEWED"
      },
      "typeVersion": 1
    },
    {
      "id": "bbbfb02b-5a4a-4f69-adb3-5d36297698b0",
      "name": "Set Support Bundle Attributes",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        224
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "SUPPORTBUNDLE_ID",
              "stringValue": "={{ $json.supportbundle_id }}"
            },
            {
              "name": "SUPPORTBUNDLE_NAME",
              "stringValue": "={{ $json.supportbundle_name }}"
            },
            {
              "name": "SUPPORTBUNDLE_UPLOADED_DATE",
              "stringValue": "={{ $json.supportbundle_uploaded_date }}"
            },
            {
              "name": "SUPPORTBUNDLE_CREATED_DATE",
              "stringValue": "={{ $json.supportbundle_created_date }}"
            },
            {
              "name": "SUPPORTBUNDLE_SOURCE",
              "stringValue": "={{ $json.supportbundle_source }}"
            },
            {
              "name": "SUPPORTBUNDLE_CUSTOMER_ID",
              "stringValue": "={{ $json.supportbundle_customer_id }}"
            },
            {
              "name": "SUPPORTBUNDLE_INSTANCE_ID",
              "stringValue": "={{ $json.supportbundle_instance_id }}"
            },
            {
              "name": "SUPPORTBUNDLE_SIZE",
              "type": "numberValue",
              "numberValue": "={{ $json.supportbundle_size }}"
            },
            {
              "name": "SUPPORTBUNDLE_VIEWED",
              "type": "booleanValue",
              "booleanValue": "={{ $json.supportbundle_viewed }}"
            }
          ]
        },
        "include": "none",
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "76d2167b-dc43-4040-a05a-717c2a08f6d1",
      "name": "Weekly Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        48,
        224
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "daeb1f3b-4983-4373-b3e5-5b789429c7c4",
      "name": "Fetch Replicated Support Bundles",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        816,
        224
      ],
      "parameters": {
        "url": "https://api.replicated.com/vendor/v3/supportbundles",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "retryOnFail": true,
      "typeVersion": 4.1,
      "alwaysOutputData": true
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2ed0541b-2c93-4109-96d2-7efa8e448154",
  "connections": {
    "Split Support Bundles": {
      "main": [
        [
          {
            "node": "Build Support Bundle Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Schedule Trigger": {
      "main": [
        [
          {
            "node": "Purge Support Bundles Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Support Bundle Fields": {
      "main": [
        [
          {
            "node": "Set Support Bundle Attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Purge Support Bundles Table": {
      "main": [
        [
          {
            "node": "Fetch Replicated Support Bundles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Support Bundle Attributes": {
      "main": [
        [
          {
            "node": "Update Replicated Bundles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Replicated Support Bundles": {
      "main": [
        [
          {
            "node": "Split Support Bundles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}