示例#1
0
        public async Task <IActionResult> GetEvents([FromRoute] long?id, [FromQuery] string name, [FromServices] ITenantRepository tenantRepository)
        {
            if (id == null)
            {
                return(JsonBadRequest("Tenant ID is required."));
            }

            Tenant tenant = tenantRepository.Get(id.Value);

            if (tenant == null)
            {
                return(JsonNotFound($"Tenant Id {id.Value} is not found."));
            }

            var result = string.IsNullOrEmpty(name) ?
                         await clusterManagementLogic.GetEventsAsync(tenant, true) :
                         await clusterManagementLogic.GetEventsAsync(tenant, name, true, false);

            if (result.IsSuccess)
            {
                return(JsonOK(result.Value));
            }
            else
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"failed to access to container: {result.Error.Name}"));
            }
        }
        public async Task <IActionResult> GetEventsByContainerName([FromRoute] long tenantId, [FromRoute] string name)
        {
            //入力チェック
            if (string.IsNullOrWhiteSpace(name))
            {
                return(JsonBadRequest("Name is required."));
            }
            //データの存在チェック
            var tenant = tenantRepository.Get(tenantId);

            if (tenant == null)
            {
                return(JsonNotFound($"Tenant ID {tenantId} is not found."));
            }

            var events = await clusterManagementLogic.GetEventsAsync(tenant, name, true, true);

            if (events.IsSuccess == false)
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to get container events: {events.Error}"));
            }
            else
            {
                return(JsonOK(events.Value));
            }
        }
        public async Task <IActionResult> UploadPreprocessImage([FromRoute] long id, [FromRoute] long dataId)
        {
            var history = await preprocessHistoryRepository.GetPreprocessIncludeDataAndPreprocessAsync(id, dataId);

            if (history == null)
            {
                return(JsonNotFound($"Preprocessing History about Preprocess {id} to Data {dataId} is not found."));
            }

            var status = ContainerStatus.Convert(history.Status);

            if (status.Exist() == false)
            {
                return(JsonBadRequest($"A container for the preprocessing does not exist."));
            }

            var events = await clusterManagementLogic.GetEventsAsync(CurrentUserInfo.SelectedTenant, history.Name, false, true);

            if (events.IsSuccess == false)
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to get container events: {events.Error}"));
            }
            else
            {
                return(JsonOK(events.Value));
            }
        }
        public async Task <IActionResult> GetErrorEventAsync(long id)
        {
            var history = await notebookHistoryRepository.GetByIdAsync(id);

            if (history == null)
            {
                return(JsonNotFound($"Notebook ID {id} is not found."));
            }
            if (history.GetStatus().Exist() == false)
            {
                return(JsonBadRequest($"A container for Notebook ID {id} does not exist."));
            }

            var events = await clusterManagementLogic.GetEventsAsync(CurrentUserInfo.SelectedTenant, history.Key, false, true);

            if (events.IsSuccess == false)
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to get container events: {events.Error}"));
            }
            else
            {
                return(JsonOK(events.Value));
            }
        }