-
Notifications
You must be signed in to change notification settings - Fork 8
/
shared_types.go
51 lines (42 loc) · 1.18 KB
/
shared_types.go
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
package megaport
import (
"encoding/json"
"time"
)
const (
SERVICE_CONFIGURED = "CONFIGURED" // The CONFIGURED service state.
SERVICE_LIVE = "LIVE" // The LIVE service state.
// Product types
PRODUCT_MEGAPORT = "megaport"
PRODUCT_VXC = "vxc"
PRODUCT_MCR = "mcr2"
PRODUCT_MVE = "mve"
PRODUCT_IX = "ix"
// Cancellation states
STATUS_DECOMMISSIONED = "DECOMMISSIONED"
STATUS_CANCELLED = "CANCELLED"
// Port Types
SINGLE_PORT = "Single"
LAG_PORT = "LAG"
// AWS VXC Types
CONNECT_TYPE_AWS_VIF = "AWS"
CONNECT_TYPE_AWS_HOSTED_CONNECTION = "AWSHC"
)
var (
// SERVICE_STATE_READY is a list of service states that are considered ready for use.
SERVICE_STATE_READY = []string{SERVICE_CONFIGURED, SERVICE_LIVE}
)
// Time is a custom time type that allows for unmarshalling of Unix timestamps.
type Time struct {
time.Time
}
// UnmarshalJSON unmarshals a Unix timestamp into a Time type.
func (t *Time) UnmarshalJSON(b []byte) error {
var timestamp int64
err := json.Unmarshal(b, ×tamp)
if err != nil {
return err
}
t.Time = time.Unix(timestamp/1000, 0) // Divide by 1000 to convert from milliseconds to seconds
return nil
}