Add Ci::Minutes::AdditionalPack create API
What does this MR do?
As part of customers-gitlab-com#2924 (closed), we are adding a new mechanism to store CI Minutes purchases.
This MR is one small part of that process:
-
adding a new table / class (!62393 (merged)) -
add an entity to represent the new model in the REST API (!63651 (merged)) -
add an API endpoint for creating new records 👈🏽 we are here
This work is all part of a larger proposal documented, here: https://gitlab.com/gitlab-org/customers-gitlab-com/blob/staging/doc/ci_minutes/provisioning_proposal.md
Additional Notes
One of the key parts of this endpoint is that we only need to create a new record if one doesn't already exist for the given namespace
/ purchase_xid
combination, which will allow us to re-sync purchases from CustomersDot without duplication.
Ideally this requirement/logic would have been supported with a unique constraint in the DB itself on the purchase_xid
column, but when we eventually migrate to using this feature exclusively for CI Minute management/provisioning, we need to continue supporting our self-managed customers using additional minutes, which was an unexpected use-case discussed here: !62393 (comment 584652714).
TLDR: when we migrate extra minute usage to this table, self-managed customers also need to be migrated/supported, but won't have a unique purchase ID (null
or default
, or some other value will likely be used, TBD).
A separate MR for handling uniqueness is in progress, here: !63866 (merged)
Docs have been added here: !63872 (merged)
Testing
curl --request POST \
--url http://127.0.0.1:3000/api/v4/namespaces/:id/minutes \
--header 'Content-Type: application/json' \
--header 'PRIVATE-TOKEN: <your token>' \
--data '{
"number_of_minutes": 123,
"expires_at": "2022-01-01",
"purchase_xid": "123abc" }'
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.