Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the snat member list in ltm? #38

Closed
lefeck opened this issue Jun 20, 2022 · 2 comments
Closed

How to get the snat member list in ltm? #38

lefeck opened this issue Jun 20, 2022 · 2 comments
Assignees
Labels
area/ltm Issues related to the ltm subpackage. kind/bug

Comments

@lefeck
Copy link

lefeck commented Jun 20, 2022

hi, @gilliek
I want to get the snat member list attribute in ltm, what should I do? We don't see the corresponding method of struct?

@gilliek gilliek self-assigned this Jun 21, 2022
@gilliek gilliek added kind/bug area/ltm Issues related to the ltm subpackage. labels Jun 21, 2022
@gilliek
Copy link
Member

gilliek commented Jun 21, 2022

Hi @lefeck

Snat API are not implemented in our client at the moment. To work around the issue you can use the following method:

https://pkg.go.dev/github.com/e-XpertSolutions/f5-rest-client/f5#Client.ReadQuery

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/e-XpertSolutions/f5-rest-client/f5"
)

func main() {
	f5Client, err := f5.NewBasicClient("https://<some-ip-address>", "admin", "admin")
	if err != nil {
		log.Fatal(err)
	}
	f5Client.DisableCertCheck()

        var data struct{
              Items []struct{
                  Name string `json:"name"`
              } `json:"items"`
        }
	if err := f5.ReadQuery("/mgmt/tm/ltm/snatpool", &data); err != nil {
              log.Fatal(err)
        }
}

Basically you just need to define the structure returned by the API and use the ReadQuery method.

If you need more attributes, you can also query the API using Postman, cURL or directly from the browser and use somehting like json-to-go to generate the Go struct for you:

https://mholt.github.io/json-to-go/

@lefeck
Copy link
Author

lefeck commented Jun 22, 2022

Thanks for the tip, I learned.

@lefeck lefeck closed this as completed Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ltm Issues related to the ltm subpackage. kind/bug
Projects
None yet
Development

No branches or pull requests

2 participants