LCOV - code coverage report
Current view: top level - model - AdminClientEndpointData.hpp (source / functions) Coverage Total Hit
Test: final-coverage.info Lines: 100.0 % 3 3
Test Date: 2025-12-16 15:55:14 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  ___________________________________________
       3              : |    _     ___                        _     |
       4              : |   | |   |__ \                      | |    |
       5              : |   | |__    ) |__ _  __ _  ___ _ __ | |_   |
       6              : |   | '_ \  / // _` |/ _` |/ _ \ '_ \| __|  |  HTTP/2 AGENT FOR MOCK TESTING
       7              : |   | | | |/ /| (_| | (_| |  __/ | | | |_   |  Version 0.0.z
       8              : |   |_| |_|____\__,_|\__, |\___|_| |_|\__|  |  https://github.com/testillano/h2agent
       9              : |                     __/ |                 |
      10              : |                    |___/                  |
      11              : |___________________________________________|
      12              : 
      13              : Licensed under the MIT License <http://opensource.org/licenses/MIT>.
      14              : SPDX-License-Identifier: MIT
      15              : Copyright (c) 2021 Eduardo Ramos
      16              : 
      17              : Permission is hereby  granted, free of charge, to any  person obtaining a copy
      18              : of this software and associated  documentation files (the "Software"), to deal
      19              : in the Software  without restriction, including without  limitation the rights
      20              : to  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell
      21              : copies  of  the Software,  and  to  permit persons  to  whom  the Software  is
      22              : furnished to do so, subject to the following conditions:
      23              : 
      24              : The above copyright notice and this permission notice shall be included in all
      25              : copies or substantial portions of the Software.
      26              : 
      27              : THE SOFTWARE  IS PROVIDED "AS  IS", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR
      28              : IMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,
      29              : FITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE
      30              : AUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER
      31              : LIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      32              : OUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE
      33              : SOFTWARE.
      34              : */
      35              : 
      36              : #pragma once
      37              : 
      38              : #include <vector>
      39              : #include <string>
      40              : 
      41              : #include <nlohmann/json.hpp>
      42              : 
      43              : #include <Map.hpp>
      44              : #include <AdminClientEndpoint.hpp>
      45              : 
      46              : #include <JsonSchema.hpp>
      47              : #include <AdminSchemas.hpp>
      48              : 
      49              : 
      50              : namespace h2agent
      51              : {
      52              : namespace model
      53              : {
      54              : 
      55              : // Map key will be string which has a hash function.
      56              : class AdminClientEndpointData : public Map<admin_client_endpoint_key_t, std::shared_ptr<AdminClientEndpoint>>
      57              : {
      58              : public:
      59              :     AdminClientEndpointData();
      60          154 :     ~AdminClientEndpointData() = default;
      61              : 
      62              :     using KeyType = admin_client_endpoint_key_t;
      63              :     using ValueType = std::shared_ptr<AdminClientEndpoint>;
      64              : 
      65              :     // Load result
      66              :     enum LoadResult { Success = 0, Accepted, BadSchema, BadContent };
      67              : 
      68              :     /**
      69              :      * Json string representation for class information (json array)
      70              :      *
      71              :      * @return Json string representation ('[]' for empty array).
      72              :      */
      73              :     std::string asJsonString() const;
      74              : 
      75              :     /**
      76              :      * Loads client endpoint operation data
      77              :      *
      78              :      * @param j json document from operation body request
      79              :      * @param cr common resources references (general configuration, global variables, file manager, mock client events data)
      80              :      *
      81              :      * @return Load operation result
      82              :      */
      83              :     LoadResult load(const nlohmann::json &j, const common_resources_t &cr);
      84              : 
      85              :     /**
      86              :      * Finds client endpoint item.
      87              :      *
      88              :      * @param id Client endpoint identifier
      89              :      *
      90              :      * @return Client endpoint information or null if missing
      91              :      */
      92              :     std::shared_ptr<AdminClientEndpoint> find(const admin_client_endpoint_key_t &id) const;
      93              : 
      94              :     /**
      95              :     * Gets client endpoint schema
      96              :     */
      97            1 :     const h2agent::jsonschema::JsonSchema& getSchema() const {
      98            1 :         return client_endpoint_schema_;
      99              :     }
     100              : 
     101              : private:
     102              : 
     103              :     h2agent::jsonschema::JsonSchema client_endpoint_schema_{};
     104              : 
     105              :     LoadResult loadSingle(const nlohmann::json &j, const common_resources_t &cr);
     106              : };
     107              : 
     108              : }
     109              : }
     110              : 
        

Generated by: LCOV version 2.0-1