NEC mBaaS Embedded SDK  6.2.0
 全て クラス ネームスペース ファイル 関数 変数 列挙型 列挙型の値
nb_service.h
説明を見る。
1 /*
2  * COPYRIGHT (C) 2017 NEC CORPORATION
3  *
4  * ALL RIGHTS RESERVED BY NEC CORPORATION, THIS PROGRAM
5  * MUST BE USED SOLELY FOR THE PURPOSE FOR WHICH IT WAS
6  * FURNISHED BY NEC CORPORATION, NO PART OF THIS PROGRAM
7  * MAY BE REPRODUCED OR DISCLOSED TO OTHERS, IN ANY FORM
8  * WITHOUT THE PRIOR WRITTEN PERMISSION OF NEC CORPORATION.
9  *
10  * NEC CONFIDENTIAL AND PROPRIETARY
11  */
12 
13 #ifndef NECBAAS_NBSERVICE_H
14 #define NECBAAS_NBSERVICE_H
15 
16 #include <string>
17 #include <memory>
18 #include "necbaas/internal/nb_session_token.h"
19 #include "necbaas/internal/nb_rest_executor.h"
20 #include "necbaas/internal/nb_rest_executor_pool.h"
21 #include "necbaas/internal/nb_http_request_factory.h"
22 
23 namespace necbaas {
24 
29 class NbService {
30  public:
45  static std::shared_ptr<NbService> CreateService(const std::string &endpoint_url, const std::string &tenant_id,
46  const std::string &app_id, const std::string &app_key,
47  const std::string &proxy = "");
48 
55  static void SetDebugLogEnabled(bool flag);
56 
63  static void SetErrorLogEnabled(bool flag);
64 
71  static void SetRestLogEnabled(bool flag);
72 
76  virtual ~NbService();
77 
82  const std::string &GetAppId() const;
83 
88  const std::string &GetAppKey() const;
89 
94  const std::string &GetEndpointUrl() const;
95 
100  const std::string &GetTenantId() const;
101 
106  const std::string &GetProxy() const;
107 
114  NbSessionToken GetSessionToken();
115 
122  virtual void SetSessionToken(const NbSessionToken &token);
123 
129  void ClearSessionToken();
130 
139  NbResult<NbHttpResponse> ExecuteRequest(std::function<NbHttpRequest(NbHttpRequestFactory &)> create_request, int timeout);
140 
150  NbResult<NbHttpResponse> ExecuteFileDownload(std::function<NbHttpRequest(NbHttpRequestFactory &)> create_request,
151  const std::string &file_path, int timeout);
152 
162  NbResult<NbHttpResponse> ExecuteFileUpload(std::function<NbHttpRequest(NbHttpRequestFactory &)> create_request,
163  const std::string &file_path, int timeout);
164  private:
165  std::string app_id_;
166  std::string app_key_;
167  std::string endpoint_url_;
168  std::string tenant_id_;
169  std::string proxy_;
170  NbSessionToken session_token_;
171  NbRestExecutorPool rest_executor_pool_;
172  std::mutex session_token_mutex_;
174  protected:
178  NbService(const std::string &endpoint_url, const std::string &tenant_id, const std::string &app_id,
179  const std::string &app_key, const std::string &proxy);
180 
187  virtual NbRestExecutor *PopRestExecutor();
188 
193  virtual void PushRestExecutor(NbRestExecutor *executor);
194 
200  NbHttpRequestFactory GetHttpRequestFactory();
201 
209  std::function<NbHttpRequest(NbHttpRequestFactory &)> create_request,
210  std::function<NbResult<NbHttpResponse>(NbRestExecutor *, const NbHttpRequest &)> executor_method);
211 };
212 } // namespace necbaas
213 #endif // NECBAAS_NBSERVICE_H
const std::string & GetAppKey() const
アプリケーションキー取得.
const std::string & GetTenantId() const
テナントID取得.
NbSessionToken GetSessionToken()
[内部処理用]
static std::shared_ptr< NbService > CreateService(const std::string &endpoint_url, const std::string &tenant_id, const std::string &app_id, const std::string &app_key, const std::string &proxy="")
サービスインスタンス生成.
MBaaS サービスクラス.
Definition: nb_service.h:29
NbResult< NbHttpResponse > ExecuteCommon(std::function< NbHttpRequest(NbHttpRequestFactory &)> create_request, std::function< NbResult< NbHttpResponse >(NbRestExecutor *, const NbHttpRequest &)> executor_method)
REST実行(共通処理).
void ClearSessionToken()
[内部処理用]
virtual NbRestExecutor * PopRestExecutor()
REST Executor 取り出し.
virtual ~NbService()
デストラクタ.
static void SetRestLogEnabled(bool flag)
ロギング設定(RESTログ).
static void SetDebugLogEnabled(bool flag)
ロギング設定(デバッグログ).
REST API処理結果クラス.
Definition: nb_result.h:32
NbService(const std::string &endpoint_url, const std::string &tenant_id, const std::string &app_id, const std::string &app_key, const std::string &proxy)
コンストラクタ.
NbResult< NbHttpResponse > ExecuteRequest(std::function< NbHttpRequest(NbHttpRequestFactory &)> create_request, int timeout)
[内部処理用]
virtual void PushRestExecutor(NbRestExecutor *executor)
REST Executor 返却.
NbResult< NbHttpResponse > ExecuteFileDownload(std::function< NbHttpRequest(NbHttpRequestFactory &)> create_request, const std::string &file_path, int timeout)
[内部処理用]
const std::string & GetProxy() const
Proxy URL取得.
const std::string & GetEndpointUrl() const
Endpoint URI 取得.
NbResult< NbHttpResponse > ExecuteFileUpload(std::function< NbHttpRequest(NbHttpRequestFactory &)> create_request, const std::string &file_path, int timeout)
[内部処理用]
NbHttpRequestFactory GetHttpRequestFactory()
HTTPリクエストファクトリ取得.
virtual void SetSessionToken(const NbSessionToken &token)
[内部処理用]
static void SetErrorLogEnabled(bool flag)
ロギング設定(エラーログ).
const std::string & GetAppId() const
アプリケーションID取得.