monolith/S02 Step 3: Write methods — create, update, delete

🎯 Why

Part of epic AR Ruby client (monolith/S02). Adds the three mutation methods on top of the Step 1 client foundation at ee/lib/artifact_registry/ (namespace ArtifactRegistry::).

Re-scoped back to ee/lib. The interim gem packaging was dropped after legal review concluded the client must ship under the EE license (decision thread on gitlab-org/gitlab!246861); the gem MRs are closed. Extracting the client into an EE-licensed gem later is tracked in #607692.

🧭 What

Add the write methods on ArtifactRegistry::Client, all building their :slug/:name paths through the Step 1 path-segment encoder (with the blank-argument and bare-./.. guards):

  • create_repository: POST, body fields, 201 -> Repository.
  • update_repository: PATCH, mutable fields only, 200 -> Repository, 404 -> ApiError (genuine not-found).
  • delete_repository: DELETE, 204 -> true, 404 -> true (idempotent, mirroring Container Registry delete_if_exists).

This step extends the private request primitive with a JSON body: parameter (the Step 1 primitive issues bodiless requests).

Files

  • ee/lib/artifact_registry/client.rb (modify: add the three methods and the body: extension)
  • ee/spec/lib/artifact_registry/client_spec.rb (modify)

Acceptance

In the EE RSpec suite (ee/spec/lib/artifact_registry/): create_repository POSTs the body -> created Repository on 201; update_repository PATCHes only the mutable fields -> updated Repository on 200, raising ApiError on 404; delete_repository -> true on 204 and on 404 (including the retried-DELETE-after-success case). A mutation 400/409/422 raises ApiError carrying the envelope. POST/PATCH are not retried on a transport failure (each issues exactly once); DELETE retries once. The :name segment is percent-encoded so a name with / or .. cannot traverse; each method attaches Authorization: Bearer through the shared request primitive.

Covers S02 acceptance criteria 3, 4, 5, 8 (POST/PATCH no-retry, DELETE retry), and the create/update 404 -> ApiError branch of 7 (plus 6 via the shared primitive).

🚩 Feature flag

None (dark by absence of a caller).

Edited by Fiona McCawley