1 package linodego
2 3 import (
4 "context"
5 "time"
6 )
7 8 // Ticket represents a support ticket object
9 type Ticket struct {
10 ID int `json:"id"`
11 Attachments []string `json:"attachments"`
12 Closed *time.Time `json:"-"`
13 Description string `json:"description"`
14 Entity *TicketEntity `json:"entity"`
15 GravatarID string `json:"gravatar_id"`
16 Opened *time.Time `json:"-"`
17 OpenedBy string `json:"opened_by"`
18 Status TicketStatus `json:"status"`
19 Summary string `json:"summary"`
20 Updated *time.Time `json:"-"`
21 UpdatedBy string `json:"updated_by"`
22 Closeable bool `json:"closeable"`
23 }
24 25 // TicketEntity refers a ticket to a specific entity
26 type TicketEntity struct {
27 ID int `json:"id"`
28 Label string `json:"label"`
29 Type string `json:"type"`
30 URL string `json:"url"`
31 }
32 33 // TicketStatus constants start with Ticket and include Linode API Ticket Status values
34 type TicketStatus string
35 36 // TicketStatus constants reflect the current status of a Ticket
37 const (
38 TicketNew TicketStatus = "new"
39 TicketClosed TicketStatus = "closed"
40 TicketOpen TicketStatus = "open"
41 )
42 43 // ListTickets returns a collection of Support Tickets on the Account. Support Tickets
44 // can be both tickets opened with Linode for support, as well as tickets generated by
45 // Linode regarding the Account. This collection includes all Support Tickets generated
46 // on the Account, with open tickets returned first.
47 func (c *Client) ListTickets(ctx context.Context, opts *ListOptions) ([]Ticket, error) {
48 return getPaginatedResults[Ticket](ctx, c, "support/tickets", opts)
49 }
50 51 // GetTicket gets a Support Ticket on the Account with the specified ID
52 func (c *Client) GetTicket(ctx context.Context, ticketID int) (*Ticket, error) {
53 e := formatAPIPath("support/tickets/%d", ticketID)
54 return doGETRequest[Ticket](ctx, c, e)
55 }
56