Exemplo n.º 1
0
        public async Task <IActionResult> GetLogByContainerName([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 fileContents = await clusterManagementLogic.DownloadLogAsync(name, tenant.Name, true);

            if (fileContents.IsSuccess == false)
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to get container log: {fileContents.Error}"));
            }
            else
            {
                return(File(fileContents.Value, "text/plain", $"{tenant.Name}_{name}_log"));
            }
        }