Documentation ¶
Overview ¶
Package explorerclient provides a simple HTTP client for the Threefold explorer API This package simplifies and reduces the dependencies from the Threefold implementation (https://github.com/threefoldtech/tfexplorer/tree/master/client) This also means not all functionality is used and only the API endpoints needed for Bancadati are implemented.
Index ¶
- Constants
- type Client
- type Date
- type Farm
- type HTTPError
- type IPRange
- type Iface
- type IfaceTypeEnum
- type Location
- type MacAddress
- type Node
- type NodeFilter
- func (n *NodeFilter) Apply(query url.Values)
- func (n *NodeFilter) WithCRU(cru int64) *NodeFilter
- func (n *NodeFilter) WithCity(city string) *NodeFilter
- func (n *NodeFilter) WithCountry(country string) *NodeFilter
- func (n *NodeFilter) WithFarm(id int64) *NodeFilter
- func (n *NodeFilter) WithHRU(hru int64) *NodeFilter
- func (n *NodeFilter) WithMRU(sru int64) *NodeFilter
- func (n *NodeFilter) WithProofs(proofs bool) *NodeFilter
- type NodeResourcePrice
- type Pager
- type PriceCurrencyEnum
- type Proof
- type PublicIface
- type ResourceAmount
- type WalletAddress
- type WorkloadAmount
Constants ¶
const (
// DefaultBaseURL represents the default API URL for the Threefold Explorer
DefaultBaseURL = "https://explorer.grid.tf/explorer/"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a TF explorer client
type Date ¶
Date is a jumpscale date wrapper
func (Date) MarshalJSON ¶
MarshalJSON formatting to JSON will return the unix time stamp
func (*Date) UnmarshalJSON ¶
UnmarshalJSON converts jumpscale data in json to Golang time.Time
type Farm ¶
type Farm struct { ID int64 `json:"id"` ThreebotID int64 `json:"threebot_id"` IyoOrganization string `json:"iyo_organization"` Name string `json:"name"` WalletAddresses []WalletAddress `json:"wallet_addresses"` Location Location `json:"location"` Email string `json:"email"` ResourcePrices []NodeResourcePrice ` json:"resource_prices"` PrefixZero IPRange `json:"prefix_zero"` }
Farm represents a farm
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError is the error type returned by the client it contains the error and the HTTP response
type IPRange ¶
IPRange type
func (IPRange) MarshalJSON ¶
MarshalJSON dumps IPRange as a string
func (*IPRange) UnmarshalText ¶
UnmarshalText loads IPRange from string
type Iface ¶
type Iface struct { Name string `json:"name"` Addrs []IPRange `json:"addrs"` Gateway []net.IP `json:"gateway"` MacAddress MacAddress `json:"macaddress"` }
Iface represents an interface
type IfaceTypeEnum ¶
type IfaceTypeEnum uint8
IfaceTypeEnum represents interface types
const ( // IfaceTypeMacvlan represents macvlan IfaceTypeMacvlan IfaceTypeEnum = iota // IfaceTypeVlan represents vlan IfaceTypeVlan )
func (IfaceTypeEnum) String ¶
func (e IfaceTypeEnum) String() string
type Location ¶
type Location struct { City string `json:"city"` Country string `json:"country"` Continent string `json:"continent"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` }
Location represents a physical location
type MacAddress ¶
type MacAddress struct{ net.HardwareAddr }
MacAddress type
func (MacAddress) MarshalText ¶
func (mac MacAddress) MarshalText() ([]byte, error)
MarshalText marshals MacAddress type to a string
func (*MacAddress) UnmarshalText ¶
func (mac *MacAddress) UnmarshalText(addr []byte) error
UnmarshalText loads a macaddress from a string
type Node ¶
type Node struct { ID int64 `json:"id"` Hostname string `json:"hostname"` NodeID string `json:"node_id"` NodeIDV1 string `json:"node_id_v1"` FarmID int64 `json:"farm_id"` OsVersion string `json:"os_version"` Created Date `json:"created"` Updated Date `json:"updated"` Uptime int64 `json:"uptime"` Address string `json:"address"` Location Location `json:"location"` TotalResources ResourceAmount `json:"total_resources"` UsedResources ResourceAmount `json:"used_resources"` ReservedResources ResourceAmount `json:"reserved_resources"` Workloads WorkloadAmount `json:"workloads"` Proofs []Proof `json:"proofs"` Ifaces []Iface `json:"ifaces"` PublicConfig *PublicIface `json:"public_config"` FreeToUse bool `json:"free_to_use"` Approved bool `json:"approved"` PublicKeyHex string `json:"public_key_hex"` WgPorts []int64 `json:"wg_ports"` }
Node represents a node
type NodeFilter ¶
type NodeFilter struct {
// contains filtered or unexported fields
}
NodeFilter used to build a query for node list
func (*NodeFilter) WithCRU ¶
func (n *NodeFilter) WithCRU(cru int64) *NodeFilter
WithCRU filter with CRU
func (*NodeFilter) WithCity ¶
func (n *NodeFilter) WithCity(city string) *NodeFilter
WithCity filter with city
func (*NodeFilter) WithCountry ¶
func (n *NodeFilter) WithCountry(country string) *NodeFilter
WithCountry filter with country
func (*NodeFilter) WithFarm ¶
func (n *NodeFilter) WithFarm(id int64) *NodeFilter
WithFarm filter with farm
func (*NodeFilter) WithHRU ¶
func (n *NodeFilter) WithHRU(hru int64) *NodeFilter
WithHRU filter with HRU
func (*NodeFilter) WithMRU ¶
func (n *NodeFilter) WithMRU(sru int64) *NodeFilter
WithMRU filter with mru
func (*NodeFilter) WithProofs ¶
func (n *NodeFilter) WithProofs(proofs bool) *NodeFilter
WithProofs filter with proofs
type NodeResourcePrice ¶
type NodeResourcePrice struct { Currency PriceCurrencyEnum `json:"currency"` Cru float64 `json:"cru"` Mru float64 `json:"mru"` Hru float64 `json:"hru"` Sru float64 `json:"sru"` Nru float64 `json:"nru"` }
NodeResourcePrice represents a node resource price
type PriceCurrencyEnum ¶
type PriceCurrencyEnum uint8
PriceCurrencyEnum represents currencies
const ( // PriceCurrencyEUR represents EUR PriceCurrencyEUR PriceCurrencyEnum = iota // PriceCurrencyUSD Represents USD PriceCurrencyUSD // PriceCurrencyTFT represents TFT PriceCurrencyTFT // PriceCurrencyAED represents AED PriceCurrencyAED // PriceCurrencyGBP represents GBP PriceCurrencyGBP )
func (PriceCurrencyEnum) String ¶
func (e PriceCurrencyEnum) String() string
type Proof ¶
type Proof struct { Created Date `json:"created"` HardwareHash string `json:"hardware_hash"` DiskHash string `json:"disk_hash"` Hardware map[string]interface{} `json:"hardware"` Disks map[string]interface{} `json:"disks"` Hypervisor []string `json:"hypervisor"` }
Proof represents proof?
type PublicIface ¶
type PublicIface struct { Master string `json:"master"` Type IfaceTypeEnum `json:"type"` Ipv4 IPRange `json:"ipv4"` Ipv6 IPRange `json:"ipv6"` Gw4 net.IP `json:"gw4"` Gw6 net.IP `json:"gw6"` Version int64 `json:"version"` }
PublicIface represents a public interface
type ResourceAmount ¶
type ResourceAmount struct { CRU uint64 `json:"cru"` MRU float64 `json:"mru"` HRU float64 `json:"hru"` SRU float64 `json:"sru"` }
ResourceAmount contains an amount for each resource
type WalletAddress ¶
WalletAddress represents a wallet address
type WorkloadAmount ¶
type WorkloadAmount struct { Network uint16 `bson:"network" json:"network"` Volume uint16 `bson:"volume" json:"volume"` ZDBNamespace uint16 `bson:"zdb_namespace" json:"zdb_namespace"` Container uint16 `bson:"container" json:"container"` K8sVM uint16 `bson:"k8s_vm" json:"k8s_vm"` Proxy uint16 `bson:"proxy" json:"proxy"` ReverseProxy uint16 `bson:"reverse_proxy" json:"reverse_proxy"` Subdomain uint16 `bson:"subdomain" json:"subdomain"` DelegateDomain uint16 `bson:"delegate_domain" json:"delegate_domain"` }
WorkloadAmount represents an amount of workload