Status endpoint
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
This commit is contained in:
@@ -380,6 +380,33 @@ app.MapGet("/RePair", async ([FromServices] ILogger<Configurator> logger, [FromS
|
|||||||
return Results.Ok(response.Content.ReadAsStringAsync());
|
return Results.Ok(response.Content.ReadAsStringAsync());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.MapGet("/Status", async ([FromServices] ILogger<Configurator> logger, [FromServices] IHttpClientFactory httpClientFactory) =>
|
||||||
|
{
|
||||||
|
string access_token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InFEc3NoM2FTV0cyT05YTTdLMzFWV0VVRW5BNCJ9.eyJpc3MiOiJodHRwczovL2ZsZWV0LWF1dGgudGVzbGEuY29tL29hdXRoMi92My9udHMiLCJhenAiOiJiMjI0MGVlNC0zMzJhLTQyNTItOTFhYS1iYmNjMjRmNzhmZGIiLCJzdWIiOiJkZDg3Mzc4OC00ZjliLTQyY2UtYmRkNi00YzdmMjQxOGMwN2UiLCJhdWQiOlsiaHR0cHM6Ly9mbGVldC1hcGkucHJkLm5hLnZuLmNsb3VkLnRlc2xhLmNvbSIsImh0dHBzOi8vZmxlZXQtYXBpLnByZC5ldS52bi5jbG91ZC50ZXNsYS5jb20iLCJodHRwczovL2ZsZWV0LWF1dGgudGVzbGEuY29tL29hdXRoMi92My91c2VyaW5mbyJdLCJzY3AiOlsib3BlbmlkIiwib2ZmbGluZV9hY2Nlc3MiLCJ2ZWhpY2xlX2RldmljZV9kYXRhIiwidmVoaWNsZV9sb2NhdGlvbiJdLCJhbXIiOlsicHdkIl0sImV4cCI6MTc1NTgwODkzNSwiaWF0IjoxNzU1NzgwMTM1LCJvdV9jb2RlIjoiRVUiLCJsb2NhbGUiOiJodS1IVSIsImFjY291bnRfdHlwZSI6InBlcnNvbiIsIm9wZW5fc291cmNlIjpmYWxzZSwiYWNjb3VudF9pZCI6IjE5YTBhZjRmLTY1ZDgtNDc2MC1hYjVmLTZjMzk3ZTViMTI4ZiIsImF1dGhfdGltZSI6MTc1NTc4MDEzNCwibm9uY2UiOiI2Mzg5MTM3NjkyNDEzMDI0MjMuTmpBNE0yWmpOalV0Wmpkak9DMDBabVF6TFdFeVlqa3RaR05rWVRKa01HSTRZMll6TnpKa09HSTNPV0V0Wmprd055MDBPREZpTFdGbE1UQXRNbVV4WlRnME1UZG1PV00xIn0.IAfZApY-P3HkRp4U2oO_T2DUFplbGfwuOfnXihcnlmiGKxKSSSuJ5aI76pcaDg9saxrhIhg17KjmEC4gL90ByDk6P7KUMp_xot0FN1Vtwy3C8_NDltebhZdM2emR5N7QHXdP4OYAQNvHwanRwBUeQthQ8pFUk9-fDzsZhwkTjrGYtvpQKZK-pn5GCLIKLib4AemsidCtfOlObjgqTd6wf_Tdb2dkbt-ACNIueTcmfXt-eFUZVRySwrvOb5pOWAUkjTUCpW074ySJjj_TDYheQHA9aTZsDJWCUNHC-51qnawiUvh-LwYWasfFhQZQisSfSusCgpGvHRVsyuLbOtd2fQ";
|
||||||
|
|
||||||
|
HttpClient client = httpClientFactory.CreateClient("InsecureClient");
|
||||||
|
client.BaseAddress = new Uri("https://tesla_command_proxy");
|
||||||
|
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {access_token}");
|
||||||
|
|
||||||
|
//Get fleet_status endpoint
|
||||||
|
string vin = "5YJ3E7EB7KF291652";
|
||||||
|
|
||||||
|
var requestObject = new { vins = new string[] { vin } };
|
||||||
|
HttpResponseMessage statusResponse = await client.PostAsJsonAsync("/api/1/vehicles/fleet_status", requestObject);
|
||||||
|
string statusResponseContent = await statusResponse.Content.ReadAsStringAsync();
|
||||||
|
logger.LogTrace("Fleet status response: {statusResponseContent}", statusResponseContent);
|
||||||
|
|
||||||
|
HttpResponseMessage responseMessage = await client.GetAsync($"/api/1/vehicles/{vin}/fleet_telemetry_errors");
|
||||||
|
string response = await responseMessage.Content.ReadAsStringAsync();
|
||||||
|
logger.LogInformation("Telemetry errors: {response}", response);
|
||||||
|
|
||||||
|
return Results.Ok(JsonSerializer.Serialize(new
|
||||||
|
{
|
||||||
|
FleetStatus = statusResponseContent,
|
||||||
|
TelemetryErrors = response
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
//Map static assets
|
//Map static assets
|
||||||
app.MapStaticAssets();
|
app.MapStaticAssets();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user