Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.7 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { azureAdAuth } from '../auth';
import { callGraphApi, groupDropdown } from '../common';

export const getGroupCustomAttributesAction = createAction({
    auth: azureAdAuth,
    name: 'get_group_custom_attributes',
    classification: 'READ',
    displayName: 'Get Group Custom Attributes',
    description: 'Gets extension and custom attributes for an Azure AD group. Returns schema extensions and open extensions.',
    audience: 'both',
    aiMetadata: {
        description:
            'Reads only the extension/custom attributes (extension_* and ext_* properties) of an Azure AD group, along with its ID and display name. Read-only and idempotent. Pick Get Group by ID when you need the standard group profile rather than custom attributes.',
        idempotent: true,
    },
    props: {
        groupId: groupDropdown,
    },
    async run(context) {
        const token = context.auth.access_token;
        const { groupId } = context.propsValue;
        // https://learn.microsoft.com/en-us/graph/api/group-get?view=graph-rest-1.0&tabs=http
        const group = await callGraphApi<Record<string, unknown>>(token, {
            method: HttpMethod.GET,
            url: `https://graph.microsoft.com/v1.0/groups/${groupId}`,
        });
        const out: Record<string, unknown> = {
            group_id: group['id'],
            group_displayName: group['displayName'],
        };
        for (const [key, value] of Object.entries(group)) {
            if (key.startsWith('extension_') || key.startsWith('ext_')) {
                out[key] = value;
            }
        }
        return out;
    },
});