File: support.go

package info (click to toggle)
golang-github-linode-linodego 1.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,112 kB
  • sloc: makefile: 96; sh: 52; python: 24
file content (55 lines) | stat: -rw-r--r-- 1,899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package linodego

import (
	"context"
	"time"
)

// Ticket represents a support ticket object
type Ticket struct {
	ID          int           `json:"id"`
	Attachments []string      `json:"attachments"`
	Closed      *time.Time    `json:"-"`
	Description string        `json:"description"`
	Entity      *TicketEntity `json:"entity"`
	GravatarID  string        `json:"gravatar_id"`
	Opened      *time.Time    `json:"-"`
	OpenedBy    string        `json:"opened_by"`
	Status      TicketStatus  `json:"status"`
	Summary     string        `json:"summary"`
	Updated     *time.Time    `json:"-"`
	UpdatedBy   string        `json:"updated_by"`
	Closeable   bool          `json:"closeable"`
}

// TicketEntity refers a ticket to a specific entity
type TicketEntity struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Type  string `json:"type"`
	URL   string `json:"url"`
}

// TicketStatus constants start with Ticket and include Linode API Ticket Status values
type TicketStatus string

// TicketStatus constants reflect the current status of a Ticket
const (
	TicketNew    TicketStatus = "new"
	TicketClosed TicketStatus = "closed"
	TicketOpen   TicketStatus = "open"
)

// ListTickets returns a collection of Support Tickets on the Account. Support Tickets
// can be both tickets opened with Linode for support, as well as tickets generated by
// Linode regarding the Account. This collection includes all Support Tickets generated
// on the Account, with open tickets returned first.
func (c *Client) ListTickets(ctx context.Context, opts *ListOptions) ([]Ticket, error) {
	return getPaginatedResults[Ticket](ctx, c, "support/tickets", opts)
}

// GetTicket gets a Support Ticket on the Account with the specified ID
func (c *Client) GetTicket(ctx context.Context, ticketID int) (*Ticket, error) {
	e := formatAPIPath("support/tickets/%d", ticketID)
	return doGETRequest[Ticket](ctx, c, e)
}