MCPcopy Create free account
hub / github.com/algolia/cli / compositionClient

Function compositionClient

pkg/cmd/factory/default.go:90–117  ·  view source on GitHub ↗
(f *cmdutil.Factory, appVersion string)

Source from the content-addressed store, hash-verified

88}
89
90func compositionClient(f *cmdutil.Factory, appVersion string) func() (*composition.APIClient, error) {
91 return func() (*composition.APIClient, error) {
92 appID, err := f.Config.Profile().GetApplicationID()
93 if err != nil {
94 return nil, err
95 }
96 apiKey, err := f.Config.Profile().GetAPIKey()
97 if err != nil {
98 return nil, err
99 }
100
101 userAgent, err := getUserAgentInfo(appID, apiKey, appVersion)
102 if err != nil {
103 return nil, err
104 }
105
106 clientConf := composition.CompositionConfiguration{
107 Configuration: transport.Configuration{
108 AppID: appID,
109 ApiKey: apiKey,
110 UserAgent: userAgent,
111 ExposeIntermediateNetworkErrors: true,
112 },
113 }
114
115 return composition.NewClientWithConfig(clientConf)
116 }
117}
118
119// getUserAgentInfo returns the standard user agent info plus Algolia CLI
120func getUserAgentInfo(appID string, apiKey string, appVersion string) (string, error) {

Callers 1

NewFunction · 0.85

Calls 4

GetApplicationIDMethod · 0.80
getUserAgentInfoFunction · 0.70
ProfileMethod · 0.65
GetAPIKeyMethod · 0.65

Tested by

no test coverage detected