LCOV - code coverage report
Current view: top level - shared_model/bindings - model_query_builder.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 1 1 100.0 %
Date: 2018-12-05 17:11:35 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #ifndef IROHA_SHARED_MODEL_MODEL_QUERY_BUILDER_HPP
       7             : #define IROHA_SHARED_MODEL_MODEL_QUERY_BUILDER_HPP
       8             : 
       9             : #include "builders/protobuf/queries.hpp"
      10             : #include "builders/protobuf/unsigned_proto.hpp"
      11             : 
      12             : namespace shared_model {
      13             :   namespace bindings {
      14             :     /**
      15             :      * Wrapper class for query builder. Designed only for SWIG bindings,
      16             :      * don't use in other cases.
      17             :      */
      18             :     class ModelQueryBuilder {
      19             :      private:
      20             :       template <int Sp>
      21             :       explicit ModelQueryBuilder(const proto::TemplateQueryBuilder<Sp> &o)
      22           3 :           : builder_(o) {}
      23             : 
      24             :      public:
      25             :       ModelQueryBuilder();
      26             : 
      27             :       /**
      28             :        * Sets time of query creation (Unix time in milliseconds)
      29             :        * @param created_time - time to set
      30             :        * @return builder with created time field appended
      31             :        */
      32             :       ModelQueryBuilder createdTime(
      33             :           interface::types::TimestampType created_time);
      34             : 
      35             :       /**
      36             :        * Sets account id of query creator
      37             :        * @param creator_account_id - account of query creator
      38             :        * @return builder with query account creator field appended
      39             :        */
      40             :       ModelQueryBuilder creatorAccountId(
      41             :           const interface::types::AccountIdType &creator_account_id);
      42             : 
      43             :       /**
      44             :        * Sets query counter
      45             :        * @param query_counter - number to set as a query counter
      46             :        * @return builder with query counter field appended
      47             :        */
      48             :       ModelQueryBuilder queryCounter(
      49             :           interface::types::CounterType query_counter);
      50             : 
      51             :       /**
      52             :        * Queries state of account
      53             :        * @param account_id - id of account to query
      54             :        * @return builder with getAccount query inside
      55             :        */
      56             :       ModelQueryBuilder getAccount(
      57             :           const interface::types::AccountIdType &account_id);
      58             : 
      59             :       /**
      60             :        * Queries signatories of account
      61             :        * @param account_id - id of account to query
      62             :        * @return builder with getSignatories query inside
      63             :        */
      64             :       ModelQueryBuilder getSignatories(
      65             :           const interface::types::AccountIdType &account_id);
      66             : 
      67             :       /**
      68             :        * Queries account transaction collection
      69             :        * @param account_id - id of account to query
      70             :        * @return builder with getAccountTransactions query inside
      71             :        */
      72             :       ModelQueryBuilder getAccountTransactions(
      73             :           const interface::types::AccountIdType &account_id);
      74             : 
      75             :       /**
      76             :        * Queries account transaction collection for a given asset
      77             :        * @param account_id - id of account to query
      78             :        * @param asset_id - asset id to query about
      79             :        * @return builder with getAccountAssetTransactions query inside
      80             :        */
      81             :       ModelQueryBuilder getAccountAssetTransactions(
      82             :           const interface::types::AccountIdType &account_id,
      83             :           const interface::types::AssetIdType &asset_id);
      84             : 
      85             :       /**
      86             :        * Queries balance of specific asset for given account
      87             :        * @param account_id - id of account to query
      88             :        * @return builder with getAccountAssets query inside
      89             :        */
      90             :       ModelQueryBuilder getAccountAssets(
      91             :           const interface::types::AccountIdType &account_id);
      92             : 
      93             :       /**
      94             :        * Queries available roles in the system
      95             :        * @return builder with getRoles query inside
      96             :        */
      97             :       ModelQueryBuilder getRoles();
      98             : 
      99             :       /**
     100             :        * Queries info about given asset
     101             :        * @param asset_id - asset id to query about
     102             :        * @return builder with getAssetInfo query inside
     103             :        */
     104             :       ModelQueryBuilder getAssetInfo(
     105             :           const interface::types::AssetIdType &asset_id);
     106             : 
     107             :       /**
     108             :        * Queries list of permissions for given role
     109             :        * @param role_id - role id to query about
     110             :        * @return builder with getRolePermissions query inside
     111             :        */
     112             :       ModelQueryBuilder getRolePermissions(
     113             :           const interface::types::RoleIdType &role_id);
     114             : 
     115             :       /**
     116             :        * Queries transactions for given hashes
     117             :        * @param hashes - list of transaction hashes to query
     118             :        * @return builder with getTransactions query inside
     119             :        */
     120             :       ModelQueryBuilder getTransactions(
     121             :           const std::vector<crypto::Hash> &hashes);
     122             : 
     123             :       /**
     124             :        * Retrieves details for a given account
     125             :        * @param account_id - account to retrieve details from
     126             :        * @param key - under which keys data should be returned
     127             :        * @param writer - from which writers details should be returned
     128             :        * @return builder with getAccountDetail query inside
     129             :        */
     130             :       ModelQueryBuilder getAccountDetail(
     131             :           const interface::types::AccountIdType &account_id = "",
     132             :           const interface::types::AccountDetailKeyType &key = "",
     133             :           const interface::types::AccountIdType &writer = "");
     134             : 
     135             :       /**
     136             :        * Retrieves all pending (not fully signed) multisignature transactions or
     137             :        * batches of transactions.
     138             :        * @return builder with getPendingTransactions query inside
     139             :        */
     140             :       ModelQueryBuilder getPendingTransactions();
     141             : 
     142             :       /**
     143             :        * Builds result with all appended fields
     144             :        * @return wrapper on unsigned query
     145             :        */
     146             :       proto::UnsignedWrapper<proto::Query> build();
     147             : 
     148             :      private:
     149             :       proto::TemplateQueryBuilder<
     150             :           (1 << shared_model::proto::TemplateQueryBuilder<>::total) - 1>
     151             :           builder_;
     152             :     };
     153             :   }  // namespace bindings
     154             : }  // namespace shared_model
     155             : 
     156             : #endif  // IROHA_SHARED_MODEL_MODEL_QUERY_BUILDER_HPP

Generated by: LCOV version 1.13