trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewr...@apache.org
Subject [incubator-trafficcontrol] 01/03: Add more documentation about the TO Client SDK
Date Mon, 14 May 2018 13:49:16 GMT
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit e25ca72d620167e3805586581b7d686316fae055
Author: Jonathan Gray <Jonathan_Gray@comcast.com>
AuthorDate: Sun May 13 22:13:39 2018 -0600

    Add more documentation about the TO Client SDK
---
 docs/source/api/traffic_ops_api.rst |  4 +++
 traffic_control/clients/README.md   | 18 +++++++++++++
 traffic_ops/client/README.md        | 54 +++++++++++++++++++++++++++++++++++++
 traffic_ops/client/v13/README.md    | 53 ++++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+)

diff --git a/docs/source/api/traffic_ops_api.rst b/docs/source/api/traffic_ops_api.rst
index 2ae61d3..a288915 100644
--- a/docs/source/api/traffic_ops_api.rst
+++ b/docs/source/api/traffic_ops_api.rst
@@ -190,3 +190,7 @@ The 3 most common errors returned by Traffic Ops are:
 
   The rest of the API documentation will only document the ``200 OK`` case, where no errors
have occured.
 
+TrafficOps Client SDK
+---------------------
+
+TrafficOps client SDK are available in both Golang and Python.  You can read more about them
at https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_control/clients
diff --git a/traffic_control/clients/README.md b/traffic_control/clients/README.md
new file mode 100644
index 0000000..7c017b1
--- /dev/null
+++ b/traffic_control/clients/README.md
@@ -0,0 +1,18 @@
+#Traffic Control Client SDK
+
+There are two client SDK supported:
+
+##Python
+* Supported TO API Versions
+  * 1.1
+  * 1.2
+* Documentation
+  * https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_control/clients/python/trafficops
+
+##Golang
+###TO API v1.2 _(Deprecated)_
+* Documentation
+  * https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_ops/client
+###TO API v1.3
+* Documentation
+  * https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_ops/client/v13
diff --git a/traffic_ops/client/README.md b/traffic_ops/client/README.md
new file mode 100644
index 0000000..e35d63e
--- /dev/null
+++ b/traffic_ops/client/README.md
@@ -0,0 +1,54 @@
+#TO Client SDK Golang
+_This version of the SDK is deprecated in favor of the newer [TO API v1.3 SDK](https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_ops/client/v13)_
+
+##Getting Started
+1. Obtain the latest version of the SDK
+
+`go get github.com/apache/incubator-trafficcontrol/traffic_ops/client`
+
+2. Get a basic TO session started and fetch a list of CDNs
+```
+package main
+
+import (
+	"fmt"
+	"os"
+	"time"
+
+	"github.com/apache/incubator-trafficcontrol/lib/go-tc/v13"
+	toclient "github.com/apache/incubator-trafficcontrol/traffic_ops/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 []v13.CDN
+	cdns, _, err = session.GetCDNs()
+	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)
+	}
+}
+```
diff --git a/traffic_ops/client/v13/README.md b/traffic_ops/client/v13/README.md
new file mode 100644
index 0000000..831b7e0
--- /dev/null
+++ b/traffic_ops/client/v13/README.md
@@ -0,0 +1,53 @@
+#TO Client SDK Golang
+
+##Getting Started
+1. Obtain the latest version of the SDK
+
+`go get github.com/apache/incubator-trafficcontrol/traffic_ops/client/v13`
+
+2. Get a basic TO session started and fetch a list of CDNs
+```
+package main
+
+import (
+	"fmt"
+	"os"
+	"time"
+
+	"github.com/apache/incubator-trafficcontrol/lib/go-tc/v13"
+	toclient "github.com/apache/incubator-trafficcontrol/traffic_ops/client/v13"
+)
+
+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 []v13.CDN
+	cdns, _, err = session.GetCDNs()
+	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)
+	}
+}
+```

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

Mime
View raw message