<commit_before>﻿using BlobService.Core.Entities;
using BlobService.Core.Models;
using BlobService.Core.Stores;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BlobService.Core.Controllers
{
    public class ContainersController : Controller
    {
        protected readonly BlobServiceOptions _options;
        protected readonly ILogger _logger;
        protected readonly IContainerMetaStore _containerMetaStore;

        public ContainersController(
            BlobServiceOptions options,
            ILogger<ContainersController> logger,
            IContainerMetaStore containerMetaStore)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _containerMetaStore = containerMetaStore ?? throw new ArgumentNullException(nameof(containerMetaStore));
        }

        [HttpGet("/containers")]
        public async Task<IEnumerable<ContainerViewModel>> GetAllContainersAsync()
        {
            var containersMetas = await _containerMetaStore.GetAllAsync();

            var containerModels = ModelMapper.ToViewModelList(containersMetas);

            return containerModels;
        }

        [HttpGet("/containers/{id}")]
        public async Task<IActionResult> GetContainerByIdAsync(string id)
        {
            if (string.IsNullOrEmpty(id)) return NotFound();

            var containerMeta = await _containerMetaStore.GetAsync(id);

            if (containerMeta == null) return NotFound();

            var containerModel = ModelMapper.ToViewModel(containerMeta);

            return Ok(containerModel);
        }

        [HttpGet("/containers?name={name}")]
        public async Task<IActionResult> GetContainerByNameAsync(string name)
        {
            if (string.IsNullOrEmpty(name)) return NotFound();

            var containerMeta = await _containerMetaStore.GetByNameAsync(name);

            if (containerMeta == null) return NotFound();

            var containerModel = ModelMapper.ToViewModel(containerMeta);

            return Ok(containerModel);
        }

        [HttpPost("/containers")]
        public async Task<IActionResult> AddContainerAsync([FromBody]ContainerCreateModel model)
        {
            if (model == null) return BadRequest();

            var containerMeta = await _containerMetaStore.AddAsync(model);
<commit_msg>remove get by container route<commit_after>﻿using BlobService.Core.Entities;
using BlobService.Core.Models;
using BlobService.Core.Stores;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BlobService.Core.Controllers
{
    public class ContainersController : Controller
    {
        protected readonly BlobServiceOptions _options;
        protected readonly ILogger _logger;
        protected readonly IContainerMetaStore _containerMetaStore;

        public ContainersController(
            BlobServiceOptions options,
            ILogger<ContainersController> logger,
            IContainerMetaStore containerMetaStore)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _containerMetaStore = containerMetaStore ?? throw new ArgumentNullException(nameof(containerMetaStore));
        }

        [HttpGet("/containers")]
        public async Task<IEnumerable<ContainerViewModel>> GetAllContainersAsync()
        {
            var containersMetas = await _containerMetaStore.GetAllAsync();

            var containerModels = ModelMapper.ToViewModelList(containersMetas);

            return containerModels;
        }

        [HttpGet("/containers/{id}")]
        public async Task<IActionResult> GetContainerByIdAsync(string id)
        {
            if (string.IsNullOrEmpty(id)) return NotFound();

            var containerMeta = await _containerMetaStore.GetAsync(id);

            if (containerMeta == null) return NotFound();

            var containerModel = ModelMapper.ToViewModel(containerMeta);

            return Ok(containerModel);
        }

        //[HttpGet("/containers?name={name}")]
        //public async Task<IActionResult> GetContainerByNameAsync(string name)
        //{
        //    if (string.IsNullOrEmpty(name)) return NotFound();

        //    var containerMeta = await _containerMetaStore.GetByNameAsync(name);

        //    if (containerMeta == null) return NotFound();

        //    var containerModel = ModelMapper.ToViewModel(containerMeta);

        //    return Ok(containerModel);
        //}

        [HttpPost("/containers")]
        public async Task<IActionResult> AddContainerAsync([FromBody]ContainerCreateModel model)
        {
            if (model == null) return BadRequest();

            var containerMeta = await _containerMetaStore.AddAsync(model);

{'fraction_non_alphanumeric': 0.08517350157728706, 'fraction_numerical': 0.0, 'mean_word_length': 2.9113338473400154, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3866033', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1216, 'n_words': 272}