// newStateForVersion creates a new client-side Uniter facade for the // given version. func newStateForVersion( caller base.APICaller, authTag names.UnitTag, version int, ) *State { facadeCaller := base.NewFacadeCallerForVersion( caller, uniterFacade, version, ) state := &State{ ModelWatcher: common.NewModelWatcher(facadeCaller), APIAddresser: common.NewAPIAddresser(facadeCaller), StorageAccessor: NewStorageAccessor(facadeCaller), facade: facadeCaller, unitTag: authTag, } newWatcher := func(result params.NotifyWatchResult) watcher.NotifyWatcher { return apiwatcher.NewNotifyWatcher(caller, result) } state.LeadershipSettings = NewLeadershipSettingsAccessor( facadeCaller.FacadeCall, newWatcher, ErrIfNotVersionFn(2, state.BestAPIVersion()), ) return state }
func (r resources) newUnitFacadeClient(unitName string, caller base.APICaller) (context.APIClient, error) { facadeCaller := base.NewFacadeCallerForVersion(caller, context.HookContextFacade, internalserver.FacadeVersion) httpClient, err := caller.HTTPClient() if err != nil { return nil, errors.Trace(err) } unitHTTPClient := internalclient.NewUnitHTTPClient(httpClient, unitName) return internalclient.NewUnitFacadeClient(facadeCaller, unitHTTPClient), nil }
func newAPIClient(apiCaller api.Connection) (*client.Client, error) { caller := base.NewFacadeCallerForVersion(apiCaller, resource.ComponentName, server.Version) httpClient, err := apiCaller.HTTPClient() if err != nil { return nil, errors.Trace(err) } // The apiCaller takes care of prepending /environment/<envUUID>. apiClient := client.NewClient(caller, httpClient, apiCaller) return apiClient, nil }
func (payloads) newListAPIClient(cmd *status.ListCommand) (status.ListAPI, error) { apiCaller, err := cmd.NewAPIRoot() if err != nil { return nil, errors.Trace(err) } caller := base.NewFacadeCallerForVersion(apiCaller, payload.ComponentName, 0) listAPI := client.NewPublicClient(&facadeCaller{ FacadeCaller: caller, closeFunc: apiCaller.Close, }) return listAPI, nil }
func (payloads) newUnitFacadeClient(caller base.APICaller) context.APIClient { facadeCaller := base.NewFacadeCallerForVersion(caller, payloadsHookContextFacade, 0) return internalclient.NewUnitFacadeClient(facadeCaller) }