Gazebo Fuel_tools

API Reference

8.2.0
gz/fuel_tools/FuelClient.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_FUEL_TOOLS_FUELCLIENT_HH_
19 #define GZ_FUEL_TOOLS_FUELCLIENT_HH_
20 
21 #include <memory>
22 #include <string>
23 #include <tuple>
24 #include <vector>
25 #include <gz/common/URI.hh>
26 
29 #include "gz/fuel_tools/Result.hh"
31 
32 #ifdef _WIN32
33 // Disable warning C4251 which is triggered by
34 // std::unique_ptr
35 #pragma warning(push)
36 #pragma warning(disable: 4251)
37 #endif
38 
39 namespace gz
40 {
41  namespace fuel_tools
42  {
44  class ClientConfig;
45  class CollectionIdentifier;
46  class FuelClientPrivate;
47  class LocalCache;
48  class ModelIdentifier;
49  class ServerConfig;
50 
52  class GZ_FUEL_TOOLS_VISIBLE FuelClient
53  {
55  public: FuelClient();
56 
61  public: FuelClient(const ClientConfig &_config,
62  const Rest &_rest = Rest());
63 
65  public: ~FuelClient();
66 
69  public: ClientConfig &Config();
70 
76  public: Result ModelDetails(const ModelIdentifier &_id,
77  ModelIdentifier &_model) const;
78 
85  public: Result ModelDetails(const ModelIdentifier &_id,
86  ModelIdentifier &_model,
87  const std::vector<std::string> &_headers) const;
88 
89 
99  public: ModelIter Models(const ServerConfig &_server);
100 
110  public: ModelIter Models(const ServerConfig &_server) const;
111 
116  public: Result WorldDetails(const WorldIdentifier &_id,
117  WorldIdentifier &_world) const;
118 
124  public: Result WorldDetails(const WorldIdentifier &_id,
125  WorldIdentifier &_world,
126  const std::vector<std::string> &_headers) const;
127 
134  public: WorldIter Worlds(const ServerConfig &_server) const;
135 
143  public: ModelIter Models(const ModelIdentifier &_id);
144 
152  public: ModelIter Models(const ModelIdentifier &_id) const;
153 
162  public: ModelIter Models(const ModelIdentifier &_id, bool _checkCache);
163 
172  public: ModelIter Models(const ModelIdentifier &_id,
173  bool _checkCache) const;
174 
179  public: ModelIter Models(const CollectionIdentifier &_id) const;
180 
184  public: WorldIter Worlds(const WorldIdentifier &_id) const;
185 
190  public: WorldIter Worlds(const CollectionIdentifier &_id) const;
191 
198  public: Result UploadModel(const std::string &_pathToModelDir,
199  const ModelIdentifier &_id,
200  const std::vector<std::string> &_headers,
201  bool _private = false);
202 
211  public: Result UploadModel(const std::string &_pathToModelDir,
212  const ModelIdentifier &_id,
213  const std::vector<std::string> &_headers,
214  bool _private,
215  const std::string &_owner);
216 
222  public: Result DeleteUrl(const gz::common::URI &_uri,
223  const std::vector<std::string> &_headers);
224 
229  public: Result DownloadModel(const ModelIdentifier &_id);
230 
236  public: Result DownloadModel(const ModelIdentifier &_id,
237  const std::vector<std::string> &_headers);
238 
245  public: Result DownloadModel(const ModelIdentifier &_id,
246  const std::vector<std::string> &_headers,
247  std::vector<ModelIdentifier> &_dependencies);
248 
253  public: Result ModelDependencies(const ModelIdentifier &_id,
254  std::vector<ModelIdentifier> &_dependencies);
255 
260  public: Result ModelDependencies(
261  const std::vector<ModelIdentifier> &_id,
262  std::vector<ModelIdentifier> &_dependencies);
263 
268  public: Result DownloadWorld(WorldIdentifier &_id);
269 
275  public: Result DownloadWorld(WorldIdentifier &_id,
276  const std::vector<std::string> &_headers);
277 
284  public: Result DownloadModel(const common::URI &_modelUrl,
285  std::string &_path);
286 
293  public: Result DownloadWorld(const common::URI &_worldUrl,
294  std::string &_path);
295 
297 
303  // The resulting vector will be at least the size of the _ids input
304  // vector, but may be larger depending on the number of depedencies
305  // downloaded
306  public: std::vector<ModelResult> DownloadModels(
307  const std::vector<ModelIdentifier> &_ids,
308  size_t _jobs = 2);
309 
314  public: Result DownloadWorlds(
315  const std::vector<WorldIdentifier> &_ids,
316  size_t _jobs = 2);
317 
323  public: Result CachedModel(const common::URI &_modelUrl,
324  std::string &_path);
325 
330  public: bool CachedModel(const common::URI &_modelUrl);
331 
337  public: Result CachedWorld(const common::URI &_worldUrl,
338  std::string &_path);
339 
344  public: bool CachedWorld(const common::URI &_worldUrl);
345 
352  public: Result CachedModelFile(const common::URI &_fileUrl,
353  std::string &_path);
354 
361  public: Result CachedWorldFile(const common::URI &_fileUrl,
362  std::string &_path);
363 
373  public: bool ParseModelUrl(const common::URI &_modelUrl,
374  ModelIdentifier &_id);
375 
385  public: bool ParseWorldUrl(const common::URI &_worldUrl,
386  WorldIdentifier &_id);
387 
397  public: bool ParseModelFileUrl(const common::URI &_modelFileUrl,
398  ModelIdentifier &_id,
399  std::string &_filePath);
400 
410  public: bool ParseWorldFileUrl(const common::URI &_worldFileUrl,
411  WorldIdentifier &_id,
412  std::string &_filePath);
413 
424  public: void PopulateLicenses(const ServerConfig &_server);
425 
435  public: Result PatchModel(
436  const gz::fuel_tools::ModelIdentifier &_model,
437  const std::vector<std::string> &_headers);
438 
452  public: Result PatchModel(
453  const gz::fuel_tools::ModelIdentifier &_model,
454  const std::vector<std::string> &_headers,
455  const std::string &_pathToModelDir);
456 
465  public: bool ParseCollectionUrl(const common::URI &_url,
466  CollectionIdentifier &_id);
467 
471  public: bool UpdateModels(const std::vector<std::string> &_headers);
472 
476  public: bool UpdateWorlds(const std::vector<std::string> &_headers);
477 
481  private: void AddServerConfigParametersToHeaders(
482  const gz::fuel_tools::ServerConfig &_serverConfig,
483  std::vector<std::string> &_headers) const;
484 
486  private: std::unique_ptr<FuelClientPrivate> dataPtr;
487  };
488  }
489 }
490 
491 #ifdef _MSC_VER
492 #pragma warning(pop)
493 #endif
494 
495 #endif