summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGanawa Juanah <ganawa@juanah.com>2024-11-18 17:29:40 -0600
committerGanawa Juanah <ganawa@juanah.com>2024-11-18 17:29:40 -0600
commit21ff93a019bc213568752b9aa2e0958dc3ccfb11 (patch)
treef3241552ee14949e52541769ed660a4df40346ab /docs
parent03593b4452ab3410565f66e4d122605dc6dc62ac (diff)
downloadvyos-documentation-21ff93a019bc213568752b9aa2e0958dc3ccfb11.tar.gz
vyos-documentation-21ff93a019bc213568752b9aa2e0958dc3ccfb11.zip
update index.rst & add vyos-govyos.rst
Diffstat (limited to 'docs')
-rw-r--r--docs/automation/index.rst4
-rw-r--r--docs/automation/vyos-govyos.rst203
2 files changed, 205 insertions, 2 deletions
diff --git a/docs/automation/index.rst b/docs/automation/index.rst
index fe70acce..f153b730 100644
--- a/docs/automation/index.rst
+++ b/docs/automation/index.rst
@@ -4,7 +4,7 @@ VyOS Automation
.. toctree::
:maxdepth: 2
-
+
vyos-api
vyos-ansible
terraform/index
@@ -14,4 +14,4 @@ VyOS Automation
command-scripting
cloud-init
vyos-pyvyos
-
+ vyos-govyos
diff --git a/docs/automation/vyos-govyos.rst b/docs/automation/vyos-govyos.rst
new file mode 100644
index 00000000..0534235f
--- /dev/null
+++ b/docs/automation/vyos-govyos.rst
@@ -0,0 +1,203 @@
+:lastproofread: 2024-03-10
+
+.. _vyos-govyos:
+
+go-vyos
+=======
+
+go-vyos is a Go library designed for interacting with VyOS devices through
+their API. This documentation is intended to guide you in using go-vyos for
+programmatic management of your VyOS devices.
+
+- `go-vyos Documentation & Source Code on GitHub <https://github.com/ganawaj/go-vyos>`_
+ allows you to access and contribute to the library's code.
+- `go-vyos on pkg.go.dev <https://pkg.go.dev/github.com/ganawaj/go-vyos@v0.1.0/vyos>`_ for detailed instructions
+ on the installation, configuration, and operation of the go-vyos library.
+
+
+Installation
+------------
+
+You can install go-vyos:
+
+.. code-block:: bash
+
+ go install "github.com/ganawaj/go-vyos/vyos"
+
+Getting Started
+---------------
+
+Importing and Disabling TLS Verification
+-------------------------------------------------
+
+.. code-block:: none
+
+ import "github.com/ganawaj/go-vyos/vyos"
+ client := vyos.NewClient(nil).WithToken("AUTH_KEY").WithURL("https://192.168.0.1").Insecure()
+
+Initializing a VyDevice Object
+------------------------------
+
+.. code-block:: none
+
+ import (
+ "github.com/ganawaj/go-vyos/vyos"
+ "os"
+ )
+
+ hostname := os.Getenv('VYDEVICE_HOSTNAME')
+ port := os.Getenv('VYDEVICE_PORT')
+ url := fmt.Sprintf("https://%s:%s", hostname, port)
+
+ apikey := os.Getenv('VYDEVICE_APIKEY')
+ verify_ssl := os.Getenv('VYDEVICE_VERIFY_SSL')
+
+ client := vyos.NewClient(nil).WithToken(apikey).WithURL(url)
+
+ if verify_ssl == "false" {
+ client = client.Insecure()
+ }
+
+Using go-vyos
+----------------
+
+Configure, then Set
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Conf.Set(ctx, "interfaces ethernet eth0 address 192.168.1.1/24")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+
+Show a Single Object Value
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Show.Do(ctx, "interfaces dummy dum1 address")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+ fmt.Printf("Data: %v\n", out.Data)
+
+Configure, then Show Object
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Conf.Get(ctx, "interfaces dummy dum1", nil)
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+ fmt.Printf("Data: %v\n", out.Data)
+
+Configure, then Show Multivalue Object
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ options := RetrieveOptions{
+ Multivalue: true,
+ }
+
+ out, resp, err := c.Conf.Get(ctx, "interfaces dummy dum1", options)
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+
+
+Configure, then Delete Object
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Conf.Delete(ctx, "interfaces dummy dum1")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+
+Configure, then Save
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Conf.Save(ctx, "")
+
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+
+Configure, then Save File
+-------------------------
+
+.. code-block:: none
+
+ out, resp, err := c.Conf.Save(ctx, "/config/test300.config")
+
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+
+Show Object
+^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Show.Do(ctx, "system image")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+ fmt.Printf("Data: %v\n", out.Data)
+
+Generate Object
+^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Generate.Do(ctx, "pki wireguard key-pair")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+ fmt.Printf("Data: %v\n", out.Data)
+
+Reset Object
+^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.Reset.Do(ctx, "ip bgp 192.0.2.11")
+ if err != nil {
+ panic("Error: %v", err)
+ }
+
+ fmt.Println(out.Success)
+ fmt.Printf("Data: %v\n", out.Data)
+
+Configure, then Load File
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: none
+
+ out, resp, err := c.ConfigFile.Load(ctx, "/config/test300.config")
+
+.. _go-vyos: https://github.com/ganawaj/go-vyos \ No newline at end of file