85 lines
3.6 KiB
JSON
85 lines
3.6 KiB
JSON
{
|
|
"name": "Clear All IP Assignments",
|
|
"description": "ONE-SHOT: Expires all MAC→IP address assignments across all customer inventory items. Run once, then delete this workflow.",
|
|
"trigger": {
|
|
"type": "MANUAL",
|
|
"nextSteps": [
|
|
{ "slug": "find-assigned-items" }
|
|
]
|
|
},
|
|
"steps": [
|
|
{
|
|
"name": "Find all inventory items assigned to accounts",
|
|
"slug": "find-assigned-items",
|
|
"type": "GAIIA_API_GATEWAY_V1_GRAPHQL_REQUEST",
|
|
"nodeSlug": "gaiia-public-api-gateway-graphql-request",
|
|
"allowSkipExecution": false,
|
|
"outputMapper": "({ output }) => {\n const items = output.response.inventoryItems.nodes;\n const withIps = [];\n for (const item of items) {\n const assignments = item.ipAddressAssignments?.nodes || [];\n for (const a of assignments) {\n if (a.isActive !== false) {\n withIps.push({\n macAddress: a.macAddress,\n ipAddress: a.ipAddress\n });\n }\n }\n }\n return withIps;\n}",
|
|
"inputs": [
|
|
{
|
|
"key": "query",
|
|
"type": "LITERAL",
|
|
"value": "string:query AllAssignedItems($filters: InventoryItemsQueryFilters, $first: Int, $after: String) {\n inventoryItems(filters: $filters, first: $first, after: $after) {\n nodes {\n ipAddressAssignments {\n nodes {\n ipAddress\n macAddress\n isActive\n }\n }\n }\n pageInfo { hasNextPage endCursor }\n totalCount\n }\n}"
|
|
},
|
|
{
|
|
"key": "variables",
|
|
"type": "LITERAL",
|
|
"value": "json:{\"filters\":{\"assigneeType\":{\"equals\":\"ACCOUNT\"}},\"first\":250}"
|
|
}
|
|
],
|
|
"nextSteps": [
|
|
{ "slug": "if-any-assignments" }
|
|
]
|
|
},
|
|
{
|
|
"name": "Any assignments to clear?",
|
|
"slug": "if-any-assignments",
|
|
"type": "CONDITION",
|
|
"nodeSlug": "condition",
|
|
"condition": "({ secrets, state, utils, variables }) => {\n const items = state.steps['find-assigned-items'].output;\n return items && items.length > 0;\n}",
|
|
"elseSteps": [{ "slug": "end" }],
|
|
"thenSteps": [{ "slug": "expire-assignments" }]
|
|
},
|
|
{
|
|
"name": "Expire each assignment",
|
|
"slug": "expire-assignments",
|
|
"type": "PARALLEL_LOOP",
|
|
"nodeSlug": "parallel-loop",
|
|
"maxConcurrentIterations": 10,
|
|
"inputs": [
|
|
{
|
|
"key": "iterable",
|
|
"type": "FUNCTION",
|
|
"value": "({ state }) => state.steps['find-assigned-items'].output"
|
|
}
|
|
],
|
|
"initialSteps": [
|
|
{ "slug": "expire-one" }
|
|
],
|
|
"nextSteps": [{ "slug": "end" }]
|
|
},
|
|
{
|
|
"name": "Expire single assignment",
|
|
"slug": "expire-one",
|
|
"type": "GAIIA_API_GATEWAY_V0_GRAPHQL_REQUEST",
|
|
"nodeSlug": "gaiia-internal-api-gateway-graphql-request",
|
|
"parentParallelLoopSlug": "expire-assignments",
|
|
"allowSkipExecution": false,
|
|
"inputs": [
|
|
{
|
|
"key": "query",
|
|
"type": "LITERAL",
|
|
"value": "string:mutation ExpireAssignation($input: UpsertMacAddressIpAddressAssignationsInput!) {\n upsertMacAddressIpAddressAssignations(input: $input) {\n assignations {\n macAddress\n ipAddress\n }\n }\n}"
|
|
},
|
|
{
|
|
"key": "variables",
|
|
"type": "FUNCTION",
|
|
"value": "({ state }) => {\n const item = state.currentParallelLoopIterations['expire-assignments'];\n return {\n input: {\n assignations: {\n macAddress: item.macAddress,\n ipAddress: item.ipAddress,\n expired: true\n }\n }\n };\n}"
|
|
}
|
|
],
|
|
"nextSteps": [
|
|
{ "slug": "expire-assignments-end" }
|
|
]
|
|
}
|
|
]
|
|
}
|