traffic

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 1

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

func (r *Data) UnmarshalJSON(b []byte) error

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

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
    }
}

type Traffic

type Traffic struct {
	// Type is a human-readable name of the type of traffic.
	Type string `json:"-"`

	// TrafficData contains information about traffic.
	TrafficData Data `json:"-"`
}

Traffic contains information about used and paid traffic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL