Skip to content

Add Ci::Minutes::AdditionalPack create API

Vijay Hawoldar requested to merge vij-add-create-ci-minutes-pack-endpoint into master

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

Availability and Testing

Edited by Etienne Baqué

Merge request reports

Loading