in src/JetBrains.Space.Generator/Program.cs [75:116]
private static async Task<int> RunGenerateFromOrganizationUrl(Dictionary<string, string?> namedArguments)
{
if (!namedArguments.TryGetValue("organizationUrl", out var organizationUrl) || string.IsNullOrEmpty(organizationUrl) ||
!namedArguments.TryGetValue("clientId", out var clientId) || string.IsNullOrEmpty(clientId) ||
!namedArguments.TryGetValue("clientSecret", out var clientSecret) || string.IsNullOrEmpty(clientSecret))
{
return await RunHelpAsync();
}
Console.WriteLine("Generating code from remote API model...");
using var httpClient = SharedHttpClient.Instance;
return await ExecuteCodeGenerator(
async () =>
{
// Load model from API
var connection = new ClientCredentialsConnection(
new Uri(organizationUrl),
clientId,
clientSecret,
httpClient);
var apiModel = await connection.RequestResourceAsync<ApiModel>(
"GET", "api/http/http-api-model?$fields=dto,enums,urlParams,resources(*,nestedResources!),menuIds", requestHeaders: null, functionName: null);
return apiModel;
},
async () =>
{
// Deployment info
var deploymentInfoClient = new DeploymentInfoClient(
organizationUrl,
httpClient);
var deploymentInfo = await deploymentInfoClient.GetDeploymentInfoAsync();
Console.WriteLine("Server information:");
Console.WriteLine(deploymentInfo);
return deploymentInfo;
});
}