Documentation ¶
Overview ¶
Package traffic provides the ability to retrieve traffic data through the Resell v2 API.
Example of getting domain traffic
domainTraffic, _, err := traffic.Get(ctx, resellClient) if err != nil { log.Fatal(err) } for _, trafficData := range domainTraffic { fmt.Println(trafficData) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct { // Start contains the start timestamp. Start time.Time `json:"-"` // Stop contains the stop timestamp. Stop time.Time `json:"-"` // Unit represents a unit that is used to represent traffic data. Unit string `json:"unit"` // Value contains traffic value for the specified period. Value int `json:"value"` }
Data represents information about traffic in the specified period.
func (*Data) UnmarshalJSON ¶
UnmarshalJSON helps to unmarshal Data timestamp fields into the needed values.
type DomainTraffic ¶
type DomainTraffic struct { // DomainData contains data about domain traffic. DomainData []*Traffic `json:"domain"` }
DomainTraffic represents domain traffic information.
func Get ¶
func Get(ctx context.Context, client *selvpcclient.ServiceClient) (*DomainTraffic, *selvpcclient.ResponseResult, error)
Get returns the domain traffic information.
func (*DomainTraffic) UnmarshalJSON ¶
func (result *DomainTraffic) UnmarshalJSON(b []byte) error
UnmarshalJSON implements custom unmarshalling method for the DomainTraffic type.
We need it to work with a JSON structure that the Resell v2 API responses with:
"domain": { "paid": { "start": "2018-04-01T00:00:00", "stop": "2018-04-30T23:59:59", "unit": "B", "value": 0 }, "prepaid": { "start": "2018-04-01T00:00:00", "stop": "2018-04-30T23:59:59", "unit": "B", "value": 3000000000000 }, "used": { "start": "2018-04-01T00:00:00", "stop": "2018-04-30T23:59:59", "unit": "B", "value": 658003816 } }
Click to show internal directories.
Click to hide internal directories.