Skip to content

feat(support-tickets): add create command to open new tickets#188

Merged
amstuta merged 1 commit into
ovh:mainfrom
jean-humann:feat/support-tickets-create
May 18, 2026
Merged

feat(support-tickets): add create command to open new tickets#188
amstuta merged 1 commit into
ovh:mainfrom
jean-humann:feat/support-tickets-create

Conversation

@jean-humann

@jean-humann jean-humann commented May 13, 2026

Copy link
Copy Markdown
Contributor

Description

Adds ovhcloud support-tickets create, which calls POST /support/tickets/create. The support-tickets subtree already exposes list / get / messages / reply — this completes the CRUD surface for the support API.

Fixes #187.

Example:

ovhcloud support-tickets create \
    --subject 'My issue' \
    --body 'Detailed description' \
    --product publiccloud \
    --category assistance \
    --service-name <id>

Implementation notes

Follows the existing IAM-user-create pattern:

  • internal/services/supporttickets/supporttickets.goCreateSpec struct (one field per request-body property) + 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 via markFlagsMutuallyExclusive. --type is wired but MarkHidden: the OpenAPI spec marks its values DEPRECATED, but keeping the flag functional means --from-file JSON payloads carrying a type field still parse without an "unknown field" error.
  • 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 for --init-file / --editor (no serviceName placeholder, so a user who runs --from-file without editing it doesn't POST a literal <your-service-id> string).
  • internal/cmd/supporttickets_test.go — happy-path test mirroring the httpmock + tdhttpmock.JSONBody pattern used by TestIAMPolicyCreateCmd, plus two error-path tests: 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.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

Test plan

  • go build ./...
  • GOOS=js GOARCH=wasm go build ./...
  • go test ./... (includes new TestSupportTicketsCreateCmd + error-path tests)
  • make doc — no spurious changes outside the new command
  • --help output renders flags grouped correctly (input flags in their own section)
  • Manual smoke against eu.api.ovh.com — ticket created end-to-end

DCO

Signed-off-by: Jean Humann <jean.humann@cleyrop.com> on the single commit.

@jean-humann jean-humann requested a review from a team as a code owner May 13, 2026 15:03
@jean-humann jean-humann force-pushed the feat/support-tickets-create branch from 8731b71 to 0a67e31 Compare May 13, 2026 15:43

@amstuta amstuta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Comment thread doc/ovhcloud_support-tickets_create.md Outdated
@jean-humann jean-humann force-pushed the feat/support-tickets-create branch from 0a67e31 to 22721ca Compare May 18, 2026 18:49
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>
@jean-humann jean-humann force-pushed the feat/support-tickets-create branch from 22721ca to 3e4dc5d Compare May 18, 2026 18:51

@amstuta amstuta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @jean-humann !

@amstuta amstuta merged commit e52a0dc into ovh:main May 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(support-tickets): add "create" command to open new tickets

2 participants