github.com/cloudfoundry/cli@v7.1.0+incompatible/api/uaa/resources.go (about)

     1  package uaa
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  
     7  	"code.cloudfoundry.org/cli/api/uaa/internal"
     8  )
     9  
    10  // SetupResources configures the client to use the specified settings and diescopers the UAA and Authentication resources
    11  func (client *Client) SetupResources(bootstrapURL string) error {
    12  	request, err := client.newRequest(requestOptions{
    13  		Method: http.MethodGet,
    14  		URL:    fmt.Sprintf("%s/login", bootstrapURL),
    15  	})
    16  
    17  	if err != nil {
    18  		return err
    19  	}
    20  
    21  	info := NewInfo(bootstrapURL)
    22  	response := Response{
    23  		Result: &info,
    24  	}
    25  
    26  	err = client.connection.Make(request, &response)
    27  	if err != nil {
    28  		return err
    29  	}
    30  
    31  	resources := map[string]string{
    32  		"uaa":                    info.UAALink(),
    33  		"authorization_endpoint": bootstrapURL,
    34  	}
    35  
    36  	client.router = internal.NewRouter(internal.APIRoutes, resources)
    37  	client.Info = info
    38  
    39  	client.config.SetUAAEndpoint(info.UAALink())
    40  
    41  	return nil
    42  }