Update photon controller go SDK in vendor code.
This commit is contained in:
32
vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go
generated
vendored
32
vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go
generated
vendored
@@ -36,12 +36,14 @@ type Client struct {
|
||||
Hosts *HostsAPI
|
||||
Deployments *DeploymentsAPI
|
||||
ResourceTickets *ResourceTicketsAPI
|
||||
Subnets *SubnetsAPI
|
||||
Networks *NetworksAPI
|
||||
VirtualSubnets *VirtualSubnetsAPI
|
||||
Clusters *ClustersAPI
|
||||
Services *ServicesAPI
|
||||
Auth *AuthAPI
|
||||
AvailabilityZones *AvailabilityZonesAPI
|
||||
Info *InfoAPI
|
||||
Routers *RoutersAPI
|
||||
Subnets *SubnetsAPI
|
||||
}
|
||||
|
||||
// Represents Tokens
|
||||
@@ -53,6 +55,8 @@ type TokenOptions struct {
|
||||
TokenType string `json:"token_type"`
|
||||
}
|
||||
|
||||
type TokenCallback func(string)
|
||||
|
||||
// Options for Client
|
||||
type ClientOptions struct {
|
||||
// When using the Tasks.Wait APIs, defines the duration of how long
|
||||
@@ -79,6 +83,11 @@ type ClientOptions struct {
|
||||
|
||||
// Tokens for user authentication. Default is empty.
|
||||
TokenOptions *TokenOptions
|
||||
|
||||
// A function to be called if the access token was refreshed
|
||||
// The client can save the new access token for future API
|
||||
// calls so that it doesn't need to be refreshed again.
|
||||
UpdateAccessTokenCallback TokenCallback
|
||||
}
|
||||
|
||||
// Creates a new photon client with specified options. If options
|
||||
@@ -110,6 +119,7 @@ func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c *
|
||||
defaultOptions.RootCAs = options.RootCAs
|
||||
}
|
||||
defaultOptions.IgnoreCertificate = options.IgnoreCertificate
|
||||
defaultOptions.UpdateAccessTokenCallback = options.UpdateAccessTokenCallback
|
||||
}
|
||||
|
||||
if logger == nil {
|
||||
@@ -124,9 +134,17 @@ func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c *
|
||||
|
||||
endpoint = strings.TrimRight(endpoint, "/")
|
||||
|
||||
tokenCallback := func(newToken string) {
|
||||
c.options.TokenOptions.AccessToken = newToken
|
||||
if c.options.UpdateAccessTokenCallback != nil {
|
||||
c.options.UpdateAccessTokenCallback(newToken)
|
||||
}
|
||||
}
|
||||
|
||||
restClient := &restClient{
|
||||
httpClient: &http.Client{Transport: tr},
|
||||
logger: logger,
|
||||
UpdateAccessTokenCallback: tokenCallback,
|
||||
}
|
||||
|
||||
c = &Client{Endpoint: endpoint, restClient: restClient, logger: logger}
|
||||
@@ -145,12 +163,18 @@ func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c *
|
||||
c.Hosts = &HostsAPI{c}
|
||||
c.Deployments = &DeploymentsAPI{c}
|
||||
c.ResourceTickets = &ResourceTicketsAPI{c}
|
||||
c.Subnets = &SubnetsAPI{c}
|
||||
c.Networks = &NetworksAPI{c}
|
||||
c.VirtualSubnets = &VirtualSubnetsAPI{c}
|
||||
c.Clusters = &ClustersAPI{c}
|
||||
c.Services = &ServicesAPI{c}
|
||||
c.Auth = &AuthAPI{c}
|
||||
c.AvailabilityZones = &AvailabilityZonesAPI{c}
|
||||
c.Info = &InfoAPI{c}
|
||||
c.Routers = &RoutersAPI{c}
|
||||
c.Subnets = &SubnetsAPI{c}
|
||||
|
||||
// Tell the restClient about the Auth API so it can request new
|
||||
// acces tokens when they expire
|
||||
restClient.Auth = c.Auth
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user