public async Task <IActionResult> AssignTo(long id, string fqdn)
        {
            SetNoCacheHeader();
            if (string.IsNullOrWhiteSpace(fqdn))
            {
                return(BadRequest("fqdn is required."));
            }

            try
            {
                if (await _nodeFactory.AssignBuildSpecification(fqdn, id))
                {
                    Logger.LogWarning($"{fqdn} was assigned to application spec {id} via an unauthenticated PUT.");
                }

                return(Ok());
            }
            catch (ArgumentException ex)
            {
                return(NotFound(ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <JsonResult> Assign(long id, long?specId)
        {
            try
            {
                await _nodeFactory.AssignBuildSpecification(id, specId, UserSecurity.SamAccountName);

                Logger.LogInformation($"Node with Inventory ID {id} was assigned to build spec {specId.GetValueOrDefault()} by {UserSecurity.SamAccountName}");
                if (specId.HasValue)
                {
                    return(Json(JsonEnvelope.Success(new
                    {
                        specUrl = Url.BuildSpecReport(specId.Value),
                        portUrl = Url.PortReport(specId.Value),
                        complianceUrl = Url.Review(specId.Value)
                    })));
                }
                return(Json(JsonEnvelope.Success()));
            }
            catch (ArgumentException)
            {
                return(Json(JsonEnvelope.Error($"A node with the id {id} was not found.")));
            }
        }