Store started_at when received from customers portal
What does this MR do and why?
The recent change to extend Duo Pro trials uncovered that we don't store the start date of Duo Pro trials. With the [data storage in place(!152857 (merged)) this MR updates the /api/v4/namespaces/#{namespace_id}/subscription_add_on_purchase/#{add_on_name}
endpoints to accept a new started_on
parameter sent from the Customers Portal application, and store that value in the started_at
column of the subscription_add_on_purchases
table.
Related Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/459962
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Boot GDK with GITLAB_SIMULATE_SAAS=1 set
- wait for GitLab to boot
- Define
GDK_INSTANCE
,NAMESPACE_ID
,ADMIN_TOKEN
in your shell, whereGDK_INSTANCE
is the base url of your GDK instance,NAMESPACE_ID
is the id of a namespace that exists within your GitLab instance and has Duo Pro seats, and ADMIN_TOKEN is an access token valid for the root user of your GDK instance. - Update an add on associated with that namespace with
curl http://$GDK_INSTANCE/api/v4/namespaces/$NAMESPACE_ID/subscription_add_on_purchase/code_suggestions -X PUT -d "{\"quantity\":5,\"started_on\":\"2024-05-24\",\"expires_on\":\"2025-06-24\",\"purchase_xid\":\"A-12345678\",\"trial\":false}" -H "Accept: application/json" -H "Content-Type: application/json" -H "PRIVATE-TOKEN: $ADMIN_TOKEN"
- Note that
started_at
is included in the response - Fetch the add on data with
curl http://$GDK_INSTANCE/api/v4/namespaces/$NAMESPACE_ID/subscription_add_on_purchase/code_suggestions -H "Accept: application/json" -H "Content-Type: application/json" -H "PRIVATE-TOKEN: $ADMIN_TOKEN"
- See that the
started_at
is present and matches what was previously set.
Edited by Allison Browne