tree: d93ce5ff69129c1f4940df94017df6eb7b3441dd [path history] [tgz]
  1. about.go
  2. api_capability.go
  3. asn.go
  4. cachegroup.go
  5. cachegroup_parameters.go
  6. capability.go
  7. cdn.go
  8. cdn_domains.go
  9. cdnfederations.go
  10. coordinate.go
  11. crconfig.go
  12. deliveryservice.go
  13. deliveryservice_regexes.go
  14. deliveryservice_request_comments.go
  15. deliveryservice_requests.go
  16. deliveryservices_required_capabilities.go
  17. deliveryserviceserver.go
  18. division.go
  19. dsuser.go
  20. endpoints.go
  21. federation.go
  22. federation_federation_resolver.go
  23. federation_resolver.go
  24. iso.go
  25. job.go
  26. log.go
  27. origin.go
  28. parameter.go
  29. phys_location.go
  30. ping.go
  31. profile.go
  32. profile_parameter.go
  33. README.md
  34. region.go
  35. role.go
  36. server.go
  37. server_server_capabilities.go
  38. server_update_status.go
  39. servercapability.go
  40. servercheck.go
  41. servercheckextensions.go
  42. serviceCategory.go
  43. session.go
  44. staticdnsentry.go
  45. stats_summary.go
  46. status.go
  47. steering.go
  48. steeringtarget.go
  49. tenant.go
  50. topology.go
  51. topology_queue_updates.go
  52. traffic_monitor.go
  53. traffic_stats.go
  54. type.go
  55. user.go
  56. util.go
traffic_ops/v3-client/README.md

Traffic Ops Go Client

Getting Started

  1. Obtain the latest version of the library

go get github.com/apache/trafficcontrol/traffic_ops/v3-client

  1. Get a basic TO session started and fetch a list of CDNs
package main

import (
	"fmt"
	"os"
	"time"

	"github.com/apache/trafficcontrol/lib/go-tc"
	toclient "github.com/apache/trafficcontrol/traffic_ops/v3-client"
)

const TOURL = "http://localhost"
const TOUser = "user"
const TOPassword = "password"
const AllowInsecureConnections = true
const UserAgent = "MySampleApp"
const UseClientCache = false
const TrafficOpsRequestTimeout = time.Second * time.Duration(10)

func main() {
	session, remoteaddr, err := toclient.LoginWithAgent(
		TOURL,
		TOUser,
		TOPassword,
		AllowInsecureConnections,
		UserAgent,
		UseClientCache,
		TrafficOpsRequestTimeout)
	if err != nil {
		fmt.Printf("An error occurred while logging in:\n\t%v\n", err)
		os.Exit(1)
	}
	fmt.Println("Connected to: " + remoteaddr.String())
	var cdns []tc.CDN
	cdns, _, err = session.GetCDNsWithHdr(nil)
	if err != nil {
		fmt.Printf("An error occurred while getting cdns:\n\t%v\n", err)
		os.Exit(1)
	}
	for _, cdn := range cdns {
		fmt.Println(cdn.Name)
	}
}