Create new internal path for AddOnPurcahse
What does this MR do and why?
Create new internal path for AddOnPurcahse
This MR adds new GET actions for add_on_purchase resource to follow the path structure: /internal/gitlab_subscriptions/
It copies the existing code from API::GitlabSubscriptions::AddOnPurchases and its corresponding spec, for GET action.
The older endpoint will be deprecated and removed in #473625 (closed).
Corresponding CustomersDot MR: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/11225+
References
- Related to #463741+
- Previous similar MR in the issue:
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
Start the GDK and CustomersDot.
-
GitLab: Create a new
top-levelgroup and find its ID, say:416 -
CustomersDot: Start a rails console, and create an
code_suggestionsadd-on for the namespaceattributes = {add_on_purchases: { duo_pro: [{quantity: 10, started_on: Date.current, expires_on: 1.year.from_now, purchase_xid: "C-00123456", trial: false}]}} Gitlab::Api::Internal::AddOnPurchase.bulk_sync(gl_namespace_id: 416, body: attributes ) => [{"namespace_id"=>416, "namespace_name"=>"test-namespace-2", "add_on"=>"Code Suggestions", "quantity"=>10, "started_on"=>"2024-11-04", "expires_on"=>"2025-11-04", "purchase_xid"=>"C-00123456", "trial"=>false}] -
CustomersDot console: Verify the new GET internal endpoint is working by fetching the recently created Add-on purchase
# check the add_on_purchase creation with GET request Client::GitlabApp.get("/api/v4/internal/gitlab_subscriptions/namespaces/416/subscription_add_on_purchases/code_suggestions", **Gitlab::Api::Internal::Authentication.token) => {"namespace_id"=>416, "namespace_name"=>"test-namespace-2", "add_on"=>"Code Suggestions", "quantity"=>10, "started_on"=>"2024-11-04", "expires_on"=>"2025-11-04", "purchase_xid"=>"C-00123456", "trial"=>false} -
On GitLab console: Check that the add-on-purchase was created and we fetched the correct add-ons
GitlabSubscriptions::AddOnPurchase.last => #<GitlabSubscriptions::AddOnPurchase:0x000000015d0dc628 id: 1016158, namespace_id: 416, quantity: 10, # ...