{ "name": "Account Status - RADIUS Suspension", "description": "EVENT: When account status changes to SUSPENDED or INACTIVE, update RADIUS usergroup to suspended. When it returns to ACTIVE, restore normal groups.", "trigger": { "type": "EVENT", "events": ["account.status_updated"], "nextSteps": [{ "slug": "get-account" }] }, "steps": [ { "name": "Get account status and products", "slug": "get-account", "type": "GAIIA_API_GATEWAY_V1_GRAPHQL_REQUEST", "nodeSlug": "gaiia-public-api-gateway-graphql-request", "allowSkipExecution": false, "outputMapper": "({ output, state }) => {\n const acct = output.response.account;\n if (!acct) {\n workflow.fail('Account not found', 'ACCOUNT_NOT_FOUND');\n }\n const status = acct.status?.name?.toUpperCase() || '';\n const products = [];\n for (const sub of (acct.billingSubscriptions?.nodes || [])) {\n const p = sub.productVersion?.product;\n if (p && !products.includes(p.id)) {\n products.push(p.id);\n }\n }\n return { status, products, accountId: acct.id };\n}", "inputs": [ { "key": "query", "type": "LITERAL", "value": "string:query GetAccount($id: GlobalID!) {\n account(id: $id) {\n id\n status { name }\n billingSubscriptions {\n nodes {\n productVersion {\n product { id name }\n }\n }\n }\n }\n}" }, { "key": "variables", "type": "FUNCTION", "value": "({ state }) => ({ id: state.input.objectId })" } ], "nextSteps": [{ "slug": "check-radius-exists" }] }, { "name": "Check if account has RADIUS usernames", "slug": "check-radius-exists", "type": "TYPESCRIPT_CODE", "nodeSlug": "execute-typescript-code", "allowSkipExecution": false, "outputMapper": "({ output, state }) => {\n const acct = state.steps['get-account'].output;\n acct.hasRadius = output && output.length > 0;\n return acct;\n}", "inputs": [ { "key": "function", "type": "FUNCTION", "value": "async ({ state, utils }) => {\n const { accountId } = state.steps['get-account'].output;\n const existingData = await utils.integration.datastore.getItem(`radiusAccount.${accountId}`);\n const accounts = existingData ? JSON.parse(existingData) : [];\n return accounts;\n}" } ], "nextSteps": [{ "slug": "should-suspend" }] }, { "name": "Should suspend?", "slug": "should-suspend", "type": "CONDITION", "nodeSlug": "condition", "condition": "({ secrets, state, utils, variables }) => {\n const { status, hasRadius } = state.steps['check-radius-exists'].output;\n return hasRadius && (status === 'SUSPENDED' || status === 'INACTIVE');\n}", "elseSteps": [{ "slug": "should-reactivate" }], "thenSteps": [{ "slug": "update-groups-suspended" }] }, { "name": "Update RADIUS groups to SUSPENDED", "slug": "update-groups-suspended", "type": "GAIIA_START_WORKFLOW_EXECUTION", "nodeSlug": "start-workflow-execution", "allowSkipExecution": false, "inputs": [ { "key": "workflowId", "type": "LITERAL", "value": "string:workflow_fLXTNCvridPqwEEXxf3CK1" }, { "key": "input", "type": "FUNCTION", "value": "({ state }) => {\n const { accountId, products, status } = state.steps['check-radius-exists'].output;\n return {\n accountId,\n status,\n productIds: products\n };\n}" }, { "key": "fireAndForget", "type": "LITERAL", "value": "boolean:true" } ], "nextSteps": [{ "slug": "end" }] }, { "name": "Should reactivate?", "slug": "should-reactivate", "type": "CONDITION", "nodeSlug": "condition", "condition": "({ secrets, state, utils, variables }) => {\n const { status, hasRadius } = state.steps['check-radius-exists'].output;\n return hasRadius && status === 'ACTIVE';\n}", "elseSteps": [{ "slug": "end" }], "thenSteps": [{ "slug": "update-groups-active" }] }, { "name": "Update RADIUS groups to ACTIVE", "slug": "update-groups-active", "type": "GAIIA_START_WORKFLOW_EXECUTION", "nodeSlug": "start-workflow-execution", "allowSkipExecution": false, "inputs": [ { "key": "workflowId", "type": "LITERAL", "value": "string:workflow_fLXTNCvridPqwEEXxf3CK1" }, { "key": "input", "type": "FUNCTION", "value": "({ state }) => {\n const { accountId, products } = state.steps['check-radius-exists'].output;\n return {\n accountId,\n status: 'ACTIVE',\n productIds: products\n };\n}" }, { "key": "fireAndForget", "type": "LITERAL", "value": "boolean:true" } ], "nextSteps": [{ "slug": "end" }] } ] }