github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/uaa/version.go (about)

     1  package uaa
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  )
     7  
     8  func (client *Client) GetAPIVersion() (string, error) {
     9  	type loginResponse struct {
    10  		App struct {
    11  			Version string `json:"version"`
    12  		} `json:"app"`
    13  	}
    14  
    15  	request, err := client.newRequest(requestOptions{
    16  		Method: http.MethodGet,
    17  		URL:    fmt.Sprintf("%s/login", client.LoginLink()),
    18  	})
    19  
    20  	if err != nil {
    21  		return "", err
    22  	}
    23  
    24  	info := loginResponse{}
    25  	response := Response{
    26  		Result: &info,
    27  	}
    28  
    29  	err = client.connection.Make(request, &response)
    30  	if err != nil {
    31  		return "", err
    32  	}
    33  
    34  	return info.App.Version, nil
    35  }