public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "salesforce/objects")] HttpRequest req, ILogger log) { string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject <QueryRequest>(requestBody); /* * name = name ?? data?.name; * * return name != null * ? (ActionResult)new OkObjectResult($"Hello, {name}") * : new BadRequestObjectResult("Please pass a name on the query string or in the request body");*/ ForceClient client = new ForceClient(data); //var result = await client.GetObjectBasicInfo(data.ObjectTypeName); var result = await client.DescribeGlobal(); return((ActionResult) new OkObjectResult(result)); }
private static async Task GenModels(GenConfig config) { ForceClient client = await Login(config); if (config.Objects == null || config.Objects.Count == 0) { Console.WriteLine("Configured list of objects to generate is empty, nothing will be generated"); return; } if (string.IsNullOrEmpty(config.AuthInfo.ApiVersion)) { config.AuthInfo.ApiVersion = client.ApiVersion; } var global = await client.DescribeGlobal(); if (string.IsNullOrEmpty(config.OutputDirectory)) { config.OutputDirectory = Directory.GetCurrentDirectory(); } Console.WriteLine("Output directory: " + config.OutputDirectory); bool generateAll = false; if (config.Objects != null && config.Objects.Count > 0) { if (config.Objects[0].ToLower() == "all") { generateAll = true; Console.WriteLine("Including all objects"); } else { Console.WriteLine("Included: " + string.Join(", ", config.Objects)); } } foreach (var obj in global.SObjects) { //TODO: verify if we should skip all non queryable? if (!obj.Queryable) { #if DEBUG Console.WriteLine("Skipping non-queryable object " + obj.Name); #endif continue; } if (!generateAll) { if (config.Objects != null && config.Objects.Count > 0) { bool incl = config.Objects.Where(o => o.ToLowerInvariant() == obj.Name.ToLowerInvariant()).Count() > 0; if (!incl) { #if DEBUG Console.WriteLine("Skipping " + obj.Name); #endif continue; } } } //TODO: verify Name and Domain non-queryable objects cause compiler errors due to name/member dupe Console.Write("Generating model for {0} - ", obj.Name); string className = obj.Name; className = string.Format("{0}{1}{2}", config.ClassPrefix ?? string.Empty, className, config.ClassSuffix ?? string.Empty); await CreateModel(client, obj.Name, className, config); } }