Skip to content

feat(incoming_email): add archestra_incoming_email org-singleton - #122

Open
priyanshu0x wants to merge 1 commit into
archestra-ai:mainfrom
priyanshu0x:feat/archestra-incoming-email
Open

priyanshu0x wants to merge 1 commit into
archestra-ai:mainfrom
priyanshu0x:feat/archestra-incoming-email

Conversation

@priyanshu0x

Copy link
Copy Markdown
Contributor

Closes #121.

Org-singleton resource modeling the platform's incoming-email webhook subscription. webhook_url is the only Required attribute (HTTPS-validated up-front because Microsoft Graph rejects plain HTTP); subscription_id / email_provider / expires_at / is_active are Computed and refreshed from GET /api/incoming-email/status. Update = re-setup, since the backend deletes any existing subscription before creating a new one — bumping webhook_url is a clean in-place change, no replace. Delete calls DELETE /api/incoming-email/subscription; 404 on Delete is treated as already-gone.

One callout: the backend's provider JSON field is renamed to email_provider on the Terraform side because provider is a reserved root-block name. The mapping is documented in the MarkdownDescription.

Verification: make lint test, make generate (no drift), TestAccIncomingEmailResource_NoProviderConfigured (pins the apply-time 400 when no org-level provider is set), and TestAccIncomingEmailResource_HttpsRequired (pins the regex validator) all green. Happy-path coverage requires a configured Outlook provider, which the local stack doesn't run; the two negative-path pins are the meaningful regression signals.

Org-singleton resource managing the platform's incoming-email
webhook subscription (Microsoft Graph for the Outlook provider).
Maps to POST /api/incoming-email/setup, GET /api/incoming-email/status,
DELETE /api/incoming-email/subscription.

Changing webhook_url is an in-place Update — the backend's setup
endpoint explicitly "Cleans up ALL existing subscriptions before
creating a new one", so RequiresReplace would needlessly thrash
state for a no-op-at-the-backend operation.

Computed `email_provider` (renamed from the wire's `provider` —
Terraform reserves `provider` as a root attribute name and the
schema fails to load otherwise), `subscription_id`, `expires_at`,
`is_active` fill in from the status endpoint. Plain-HTTP URLs are
rejected client-side (Microsoft Graph wouldn't accept them anyway).

Un-excluded the `Incoming Email` OpenAPI tag in oapi-config.yaml
and regenerated internal/client.

Real happy-path testing requires a real Microsoft Graph tenant +
publicly-reachable webhook URL the platform can subscribe to; the
local stack ships without an email-provider credential, so the two
shipped acceptance tests pin the validate-time HTTPS check and the
backend's 400-on-no-provider-configured path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(incoming_email): expose org-singleton incoming-email webhook subscription

1 participant