public async Task <HttpResponseData> SearchStates([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "testhooks/nodeOperations/searchStates")] HttpRequestData req) { _log.Info("search states"); var query = UriExtension.GetQueryComponents(req.Url); Guid?poolId = UriExtension.GetGuid("poolId", query); Guid?scaleSetId = UriExtension.GetGuid("scaleSetId", query); List <NodeState>?states = default; if (query.ContainsKey("states")) { states = query["states"].Split('-').Select(s => Enum.Parse <NodeState>(s)).ToList(); } string?poolNameString = UriExtension.GetString("poolName", query); PoolName?poolName = poolNameString is null ? null : PoolName.Parse(poolNameString); var excludeUpdateScheduled = UriExtension.GetBool("excludeUpdateScheduled", query, false); int?numResults = UriExtension.GetInt("numResults", query); var r = _nodeOps.SearchStates(poolId, scaleSetId, states, poolName, excludeUpdateScheduled, numResults); var json = JsonSerializer.Serialize(await r.ToListAsync(), EntityConverter.GetJsonSerializerOptions()); var resp = req.CreateResponse(HttpStatusCode.OK); await resp.WriteStringAsync(json); return(resp); }
public async Task <HttpResponseData> CreateNode([HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = "testhooks/nodeOperations/node")] HttpRequestData req) { _log.Info("create node"); var query = UriExtension.GetQueryComponents(req.Url); Guid poolId = Guid.Parse(query["poolId"]); var poolName = PoolName.Parse(query["poolName"]); Guid machineId = Guid.Parse(query["machineId"]); Guid?scaleSetId = default; if (query.ContainsKey("scaleSetId")) { scaleSetId = Guid.Parse(query["scaleSetId"]); } string version = query["version"]; bool isNew = UriExtension.GetBool("isNew", query, false); var node = await _nodeOps.Create(poolId, poolName, machineId, scaleSetId, version, isNew); var resp = req.CreateResponse(HttpStatusCode.OK); await resp.WriteAsJsonAsync(JsonSerializer.Serialize(node, EntityConverter.GetJsonSerializerOptions())); return(resp); }
public async Task <HttpResponseData> ToReimage([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "testhooks/nodeOperations/toReimage")] HttpRequestData req) { _log.Info("to reimage"); var query = UriExtension.GetQueryComponents(req.Url); var done = UriExtension.GetBool("done", query, false); var s = await req.ReadAsStringAsync(); var node = JsonSerializer.Deserialize <Node>(s !, EntityConverter.GetJsonSerializerOptions()); var r = _nodeOps.ToReimage(node !, done); var resp = req.CreateResponse(HttpStatusCode.OK); await resp.WriteAsJsonAsync(r); return(resp); }