@@ -29,7 +29,7 @@ func NewAgentClient(url string, apiKey string, apiSecret string, opts ...AgentCl
2929 }
3030 c := & AgentClient {
3131 authBase : authBase {apiKey , apiSecret },
32- httpClient : & http. Client {} ,
32+ httpClient : newAPIHTTPClient () ,
3333 }
3434 for _ , opt := range opts {
3535 opt (c )
@@ -53,143 +53,143 @@ func WithTwirpClientOptions(opts ...twirp.ClientOption) AgentClientOption {
5353}
5454
5555func (c * AgentClient ) CreateAgent (ctx context.Context , req * livekit.CreateAgentRequest ) (* livekit.CreateAgentResponse , error ) {
56- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
56+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
5757 if err != nil {
5858 return nil , err
5959 }
6060 return c .agentClient .CreateAgent (ctx , req )
6161}
6262
6363func (c * AgentClient ) CreateAgentV2 (ctx context.Context , req * livekit.CreateAgentV2Request ) (* livekit.CreateAgentV2Response , error ) {
64- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
64+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
6565 if err != nil {
6666 return nil , err
6767 }
6868 return c .agentClient .CreateAgentV2 (ctx , req )
6969}
7070
7171func (c * AgentClient ) ListAgents (ctx context.Context , req * livekit.ListAgentsRequest ) (* livekit.ListAgentsResponse , error ) {
72- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
72+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
7373 if err != nil {
7474 return nil , err
7575 }
7676 return c .agentClient .ListAgents (ctx , req )
7777}
7878
7979func (c * AgentClient ) ListAgentVersions (ctx context.Context , req * livekit.ListAgentVersionsRequest ) (* livekit.ListAgentVersionsResponse , error ) {
80- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
80+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
8181 if err != nil {
8282 return nil , err
8383 }
8484 return c .agentClient .ListAgentVersions (ctx , req )
8585}
8686
8787func (c * AgentClient ) DeleteAgent (ctx context.Context , req * livekit.DeleteAgentRequest ) (* livekit.DeleteAgentResponse , error ) {
88- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
88+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
8989 if err != nil {
9090 return nil , err
9191 }
9292 return c .agentClient .DeleteAgent (ctx , req )
9393}
9494
9595func (c * AgentClient ) UpdateAgent (ctx context.Context , req * livekit.UpdateAgentRequest ) (* livekit.UpdateAgentResponse , error ) {
96- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
96+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
9797 if err != nil {
9898 return nil , err
9999 }
100100 return c .agentClient .UpdateAgent (ctx , req )
101101}
102102
103103func (c * AgentClient ) RestartAgent (ctx context.Context , req * livekit.RestartAgentRequest ) (* livekit.RestartAgentResponse , error ) {
104- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
104+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
105105 if err != nil {
106106 return nil , err
107107 }
108108 return c .agentClient .RestartAgent (ctx , req )
109109}
110110
111111func (c * AgentClient ) RollbackAgent (ctx context.Context , req * livekit.RollbackAgentRequest ) (* livekit.RollbackAgentResponse , error ) {
112- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
112+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
113113 if err != nil {
114114 return nil , err
115115 }
116116 return c .agentClient .RollbackAgent (ctx , req )
117117}
118118
119119func (c * AgentClient ) ListAgentSecrets (ctx context.Context , req * livekit.ListAgentSecretsRequest ) (* livekit.ListAgentSecretsResponse , error ) {
120- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
120+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
121121 if err != nil {
122122 return nil , err
123123 }
124124 return c .agentClient .ListAgentSecrets (ctx , req )
125125}
126126
127127func (c * AgentClient ) UpdateAgentSecrets (ctx context.Context , req * livekit.UpdateAgentSecretsRequest ) (* livekit.UpdateAgentSecretsResponse , error ) {
128- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
128+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
129129 if err != nil {
130130 return nil , err
131131 }
132132 return c .agentClient .UpdateAgentSecrets (ctx , req )
133133}
134134
135135func (c * AgentClient ) DeployAgent (ctx context.Context , req * livekit.DeployAgentRequest ) (* livekit.DeployAgentResponse , error ) {
136- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
136+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
137137 if err != nil {
138138 return nil , err
139139 }
140140 return c .agentClient .DeployAgent (ctx , req )
141141}
142142
143143func (c * AgentClient ) DeployAgentV2 (ctx context.Context , req * livekit.DeployAgentV2Request ) (* livekit.DeployAgentV2Response , error ) {
144- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
144+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
145145 if err != nil {
146146 return nil , err
147147 }
148148 return c .agentClient .DeployAgentV2 (ctx , req )
149149}
150150
151151func (c * AgentClient ) PromoteAgent (ctx context.Context , req * livekit.PromoteAgentRequest ) (* livekit.PromoteAgentResponse , error ) {
152- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
152+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
153153 if err != nil {
154154 return nil , err
155155 }
156156 return c .agentClient .PromoteAgent (ctx , req )
157157}
158158
159159func (c * AgentClient ) GetClientSettings (ctx context.Context , req * livekit.ClientSettingsRequest ) (* livekit.ClientSettingsResponse , error ) {
160- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
160+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
161161 if err != nil {
162162 return nil , err
163163 }
164164 return c .agentClient .GetClientSettings (ctx , req )
165165}
166166
167167func (c * AgentClient ) CreatePrivateLink (ctx context.Context , req * livekit.CreatePrivateLinkRequest ) (* livekit.CreatePrivateLinkResponse , error ) {
168- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
168+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
169169 if err != nil {
170170 return nil , err
171171 }
172172 return c .agentClient .CreatePrivateLink (ctx , req )
173173}
174174
175175func (c * AgentClient ) DestroyPrivateLink (ctx context.Context , req * livekit.DestroyPrivateLinkRequest ) (* livekit.DestroyPrivateLinkResponse , error ) {
176- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
176+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
177177 if err != nil {
178178 return nil , err
179179 }
180180 return c .agentClient .DestroyPrivateLink (ctx , req )
181181}
182182
183183func (c * AgentClient ) ListPrivateLinks (ctx context.Context , req * livekit.ListPrivateLinksRequest ) (* livekit.ListPrivateLinksResponse , error ) {
184- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
184+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
185185 if err != nil {
186186 return nil , err
187187 }
188188 return c .agentClient .ListPrivateLinks (ctx , req )
189189}
190190
191191func (c * AgentClient ) GetPrivateLinkStatus (ctx context.Context , req * livekit.GetPrivateLinkStatusRequest ) (* livekit.GetPrivateLinkStatusResponse , error ) {
192- ctx , err := c .withAuth (ctx , withAgentGrant {Admin : true })
192+ ctx , err := c .prepareContext (ctx , withAgentGrant {Admin : true })
193193 if err != nil {
194194 return nil , err
195195 }
0 commit comments