Move towards explicit types
This commit is contained in:
@@ -31,12 +31,12 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
||||
|
||||
public async Task<List<IPGeoFeed>> GetGeoFeedData()
|
||||
{
|
||||
var geoFeed = new List<IPGeoFeed>();
|
||||
using var client = httpClientFactory.CreateClient();
|
||||
List<IPGeoFeed> geoFeed = new List<IPGeoFeed>();
|
||||
using HttpClient client = httpClientFactory.CreateClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", configuration["APIKey"]);
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
foreach (var family in addressFamilies)
|
||||
foreach (AddressFamily family in addressFamilies)
|
||||
{
|
||||
Uri uri = BuildNetBoxURI(family);
|
||||
NetboxData? jsonData = null;
|
||||
@@ -45,10 +45,10 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
||||
{
|
||||
logger.LogDebug($"Making request to {uri}...");
|
||||
|
||||
using var result = await client.GetAsync(uri);
|
||||
using HttpResponseMessage result = await client.GetAsync(uri);
|
||||
if (result.IsSuccessStatusCode)
|
||||
{
|
||||
var stringResult = await result.Content.ReadAsStringAsync();
|
||||
string stringResult = await result.Content.ReadAsStringAsync();
|
||||
jsonData = JsonConvert.DeserializeObject<NetboxData>(stringResult);
|
||||
|
||||
if (jsonData?.Results == null || jsonData.Results.Count == 0)
|
||||
@@ -56,7 +56,7 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var data in jsonData.Results)
|
||||
foreach (Result data in jsonData.Results)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
||||
|
||||
protected Uri BuildNetBoxURI(AddressFamily family)
|
||||
{
|
||||
var queryParameters = HttpUtility.ParseQueryString(string.Empty);
|
||||
System.Collections.Specialized.NameValueCollection queryParameters = HttpUtility.ParseQueryString(string.Empty);
|
||||
queryParameters["cf_geoloc_has_location"] = "true";
|
||||
queryParameters["limit"] = "50";
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
||||
break;
|
||||
}
|
||||
|
||||
var endUrl = new UriBuilder
|
||||
UriBuilder endUrl = new UriBuilder
|
||||
{
|
||||
Path = "api/ipam/prefixes/",
|
||||
Query = queryParameters.ToString(),
|
||||
|
||||
Reference in New Issue
Block a user