| 
									
										
										
										
											2021-07-05 18:20:12 +08:00
										 |  |  | package azuremonitor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"net/http" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 17:23:13 +08:00
										 |  |  | 	"github.com/grafana/grafana-azure-sdk-go/azhttpclient" | 
					
						
							| 
									
										
										
										
											2022-04-01 19:26:49 +08:00
										 |  |  | 	sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient" | 
					
						
							| 
									
										
										
										
											2022-04-04 17:23:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 19:26:49 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/infra/httpclient" | 
					
						
							| 
									
										
										
										
											2021-07-05 18:20:12 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/setting" | 
					
						
							| 
									
										
										
										
											2022-03-02 22:41:07 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types" | 
					
						
							| 
									
										
										
										
											2021-07-05 18:20:12 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-02 22:41:07 +08:00
										 |  |  | func newHTTPClient(route types.AzRoute, model types.DatasourceInfo, cfg *setting.Cfg, clientProvider httpclient.Provider) (*http.Client, error) { | 
					
						
							| 
									
										
										
										
											2022-04-01 19:26:49 +08:00
										 |  |  | 	opts := sdkhttpclient.Options{ | 
					
						
							| 
									
										
										
										
											2022-04-28 16:27:39 +08:00
										 |  |  | 		Headers: route.Headers, | 
					
						
							| 
									
										
										
										
											2022-04-01 19:26:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Use Azure credentials if the route has OAuth scopes configured
 | 
					
						
							|  |  |  | 	if len(route.Scopes) > 0 { | 
					
						
							|  |  |  | 		azhttpclient.AddAzureAuthentication(&opts, cfg.Azure, model.Credentials, route.Scopes) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return clientProvider.New(opts) | 
					
						
							| 
									
										
										
										
											2021-07-05 18:20:12 +08:00
										 |  |  | } |