/
fabric_service_tokens.go
42 lines (35 loc) · 1.37 KB
/
fabric_service_tokens.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
package packngo
import "path"
type FabricServiceTokenType string
const (
fabricServiceTokenBasePath = "/fabric-service-tokens"
FabricServiceTokenASide FabricServiceTokenType = "a_side"
FabricServiceTokenZSide FabricServiceTokenType = "z_side"
)
// FabricServiceToken represents an Equinix Metal metro
type FabricServiceToken struct {
*Href `json:",inline"`
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
ID string `json:"id"`
MaxAllowedSpeed uint64 `json:"max_allowed_speed,omitempty"`
Role ConnectionPortRole `json:"role,omitempty"`
ServiceTokenType FabricServiceTokenType `json:"service_token_type,omitempty"`
State string `json:"state,omitempty"`
}
func (f FabricServiceToken) String() string {
return Stringify(f)
}
// FabricServiceTokenServiceOp implements FabricServiceTokenService
type FabricServiceTokenServiceOp struct {
client *Client
}
func (s *FabricServiceTokenServiceOp) Get(id string, opts *GetOptions) (*FabricServiceToken, *Response, error) {
endpointPath := path.Join(fabricServiceTokenBasePath, id)
apiPathQuery := opts.WithQuery(endpointPath)
fst := new(FabricServiceToken)
resp, err := s.client.DoRequest("GET", apiPathQuery, nil, fst)
if err != nil {
return nil, resp, err
}
return fst, resp, err
}