feat(support-tickets): add create command to open new tickets#188
Merged
Conversation
8731b71 to
0a67e31
Compare
amstuta
reviewed
May 18, 2026
amstuta
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this PR @jean-humann ! I just mentionned a small fix to do in the doc, and after that we're good to merge :)
0a67e31 to
22721ca
Compare
Closes ovh#187. The support-tickets subtree already exposes list / get / messages / reply but not the POST /support/tickets/create endpoint, so users must fall back to the web console (or a raw curl call) to open a ticket from a script or oncall runbook. This change adds: ovhcloud support-tickets create \ --subject 'My issue' --body '...' \ --product publiccloud --category assistance --service-name <id> Implementation follows the existing IAM-user-create pattern: - internal/services/supporttickets/supporttickets.go: CreateSpec struct + TicketCreateExample embed + CreateSupportTicket(cmd, _) that delegates to common.CreateResource with mandatory fields ["body", "subject"]. Output prefers ticketId / ticketNumber from the response, with a nil-value guard so a JSON-null id falls through to a generic success message. - internal/cmd/supporttickets.go: cobra subcommand exposing typed flags for every field of the request body (subject, body, category, product, service-name, subcategory, impact, urgency, type, watchers) plus the standard --from-file / --init-file / --editor UX helpers (--from-file and --editor marked mutually exclusive). The --type flag is wired but MarkHidden: the OpenAPI spec marks its values DEPRECATED, but keeping it functional lets --from-file JSON payloads that still carry a 'type' field continue to parse. - internal/assets/{assets,assets_wasm}.go: embed support.json (fetched via 'make schemas UNIVERSE=support'). - internal/services/supporttickets/parameter-samples/ticket-create.json: minimal example body used by --init-file / --editor; no serviceName placeholder so users who run --from-file without editing it don't POST a literal '<your-service-id>' string. - internal/cmd/supporttickets_test.go: happy-path test (matches the existing httpmock + testdeep pattern used by TestIAMPolicyCreateCmd) + two error-path tests covering the mandatory-field check ('mandatory field \"subject\" is missing') and the --from-file / --editor mutual-exclusion guard. - doc/ovhcloud_support-tickets*.md: regenerated via 'make doc'. Verified locally: - go build ./... - GOOS=js GOARCH=wasm go build ./... - go test ./... Signed-off-by: Jean Humann <jean.humann@cleyrop.com>
22721ca to
3e4dc5d
Compare
amstuta
approved these changes
May 18, 2026
amstuta
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your contribution @jean-humann !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
ovhcloud support-tickets create, which callsPOST /support/tickets/create. Thesupport-ticketssubtree already exposeslist/get/messages/reply— this completes the CRUD surface for the support API.Fixes #187.
Example:
Implementation notes
Follows the existing IAM-user-create pattern:
internal/services/supporttickets/supporttickets.go—CreateSpecstruct (one field per request-body property) +TicketCreateExampleembed +CreateSupportTicket(cmd, _)that delegates tocommon.CreateResourcewith mandatory fields["body", "subject"]. Output prefersticketId+ticketNumberfrom the response, with a nil-value guard so a JSON-null id falls through to a generic success message.internal/cmd/supporttickets.go— cobra subcommand exposing typed flags for every field of the request body (--subject,--body,--category,--product,--service-name,--subcategory,--impact,--urgency,--type,--watchers) plus the standard--from-file/--init-file/--editorUX helpers.--from-fileand--editormarked mutually exclusive viamarkFlagsMutuallyExclusive.--typeis wired butMarkHidden: the OpenAPI spec marks its values DEPRECATED, but keeping the flag functional means--from-fileJSON payloads carrying atypefield still parse without an "unknown field" error.internal/assets/{assets,assets_wasm}.go— embedsupport.json, fetched viamake schemas UNIVERSE=support.internal/services/supporttickets/parameter-samples/ticket-create.json— minimal example body for--init-file/--editor(noserviceNameplaceholder, so a user who runs--from-filewithout editing it doesn't POST a literal<your-service-id>string).internal/cmd/supporttickets_test.go— happy-path test mirroring thehttpmock+tdhttpmock.JSONBodypattern used byTestIAMPolicyCreateCmd, plus two error-path tests: mandatory-field check (mandatory field "subject" is missing) and the--from-file/--editormutual-exclusion guard.doc/ovhcloud_support-tickets*.md— regenerated viamake doc.Type of change
Checklist:
go mod tidyTest plan
go build ./...GOOS=js GOARCH=wasm go build ./...go test ./...(includes newTestSupportTicketsCreateCmd+ error-path tests)make doc— no spurious changes outside the new command--helpoutput renders flags grouped correctly (input flags in their own section)eu.api.ovh.com— ticket created end-to-endDCO
Signed-off-by: Jean Humann <jean.humann@cleyrop.com>on the single commit.