Gazebo Fuel_tools

API Reference

7.3.1
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 
27 #include "gz/fuel_tools/Helpers.hh"
30 #include "gz/fuel_tools/Result.hh"
32 
33 #ifdef _WIN32
34 // Disable warning C4251 which is triggered by
35 // std::unique_ptr
36 #pragma warning(push)
37 #pragma warning(disable: 4251)
38 #endif
39 
40 namespace ignition
41 {
42  namespace fuel_tools
43  {
45  class ClientConfig;
46  class CollectionIdentifier;
47  class FuelClientPrivate;
48  class LocalCache;
49  class ModelIdentifier;
50  class ServerConfig;
51 
53  class IGNITION_FUEL_TOOLS_VISIBLE FuelClient
54  {
56  public: FuelClient();
57 
62  public: FuelClient(const ClientConfig &_config,
63  const Rest &_rest = Rest());
64 
73  // cppcheck-suppress unknownMacro
74  public: IGN_DEPRECATED(6) FuelClient(const ClientConfig &_config,
75  const Rest &_rest,
76  LocalCache *_cache);
77 
79  public: ~FuelClient();
80 
83  public: ClientConfig &Config();
84 
90  public: Result ModelDetails(const ModelIdentifier &_id,
91  ModelIdentifier &_model) const;
92 
99  public: Result ModelDetails(const ModelIdentifier &_id,
100  ModelIdentifier &_model,
101  const std::vector<std::string> &_headers) const;
102 
103 
113  public: ModelIter Models(const ServerConfig &_server);
114 
124  public: ModelIter Models(const ServerConfig &_server) const;
125 
130  public: Result WorldDetails(const WorldIdentifier &_id,
131  WorldIdentifier &_world) const;
132 
138  public: Result WorldDetails(const WorldIdentifier &_id,
139  WorldIdentifier &_world,
140  const std::vector<std::string> &_headers) const;
141 
148  public: WorldIter Worlds(const ServerConfig &_server) const;
149 
157  public: ModelIter Models(const ModelIdentifier &_id);
158 
166  public: ModelIter Models(const ModelIdentifier &_id) const;
167 
176  public: ModelIter Models(const ModelIdentifier &_id, bool _checkCache);
177 
186  public: ModelIter Models(const ModelIdentifier &_id,
187  bool _checkCache) const;
188 
193  public: ModelIter Models(const CollectionIdentifier &_id) const;
194 
198  public: WorldIter Worlds(const WorldIdentifier &_id) const;
199 
204  public: WorldIter Worlds(const CollectionIdentifier &_id) const;
205 
212  public: Result UploadModel(const std::string &_pathToModelDir,
213  const ModelIdentifier &_id,
214  const std::vector<std::string> &_headers,
215  bool _private = false);
216 
225  public: Result UploadModel(const std::string &_pathToModelDir,
226  const ModelIdentifier &_id,
227  const std::vector<std::string> &_headers,
228  bool _private,
229  const std::string &_owner);
230 
234  public: Result IGN_DEPRECATED(6) DeleteModel(const ModelIdentifier &_id);
235 
241  public: Result DeleteUrl(const gz::common::URI &_uri,
242  const std::vector<std::string> &_headers);
243 
248  public: Result DownloadModel(const ModelIdentifier &_id);
249 
255  public: Result DownloadModel(const ModelIdentifier &_id,
256  const std::vector<std::string> &_headers);
257 
264  public: Result DownloadModel(const ModelIdentifier &_id,
265  const std::vector<std::string> &_headers,
266  std::vector<ModelIdentifier> &_dependencies);
267 
272  public: Result ModelDependencies(const ModelIdentifier &_id,
273  std::vector<ModelIdentifier> &_dependencies);
274 
279  public: Result ModelDependencies(
280  const std::vector<ModelIdentifier> &_id,
281  std::vector<ModelIdentifier> &_dependencies);
282 
287  public: Result DownloadWorld(WorldIdentifier &_id);
288 
294  public: Result DownloadWorld(WorldIdentifier &_id,
295  const std::vector<std::string> &_headers);
296 
303  public: Result DownloadModel(const common::URI &_modelUrl,
304  std::string &_path);
305 
312  public: Result DownloadWorld(const common::URI &_worldUrl,
313  std::string &_path);
314 
316 
322  // The resulting vector will be at least the size of the _ids input
323  // vector, but may be larger depending on the number of depedencies
324  // downloaded
325  public: std::vector<ModelResult> DownloadModels(
326  const std::vector<ModelIdentifier> &_ids,
327  size_t _jobs = 2);
328 
333  public: Result DownloadWorlds(
334  const std::vector<WorldIdentifier> &_ids,
335  size_t _jobs = 2);
336 
342  public: Result CachedModel(const common::URI &_modelUrl,
343  std::string &_path);
344 
349  public: bool CachedModel(const common::URI &_modelUrl);
350 
356  public: Result CachedWorld(const common::URI &_worldUrl,
357  std::string &_path);
358 
363  public: bool CachedWorld(const common::URI &_worldUrl);
364 
371  public: Result CachedModelFile(const common::URI &_fileUrl,
372  std::string &_path);
373 
380  public: Result CachedWorldFile(const common::URI &_fileUrl,
381  std::string &_path);
382 
392  public: bool ParseModelUrl(const common::URI &_modelUrl,
393  ModelIdentifier &_id);
394 
404  public: bool ParseWorldUrl(const common::URI &_worldUrl,
405  WorldIdentifier &_id);
406 
416  public: bool ParseModelFileUrl(const common::URI &_modelFileUrl,
417  ModelIdentifier &_id,
418  std::string &_filePath);
419 
429  public: bool ParseWorldFileUrl(const common::URI &_worldFileUrl,
430  WorldIdentifier &_id,
431  std::string &_filePath);
432 
443  public: void PopulateLicenses(const ServerConfig &_server);
444 
454  public: Result PatchModel(
455  const gz::fuel_tools::ModelIdentifier &_model,
456  const std::vector<std::string> &_headers);
457 
471  public: Result PatchModel(
472  const gz::fuel_tools::ModelIdentifier &_model,
473  const std::vector<std::string> &_headers,
474  const std::string &_pathToModelDir);
475 
484  public: bool ParseCollectionUrl(const common::URI &_url,
485  CollectionIdentifier &_id);
486 
490  public: bool UpdateModels(const std::vector<std::string> &_headers);
491 
495  public: bool UpdateWorlds(const std::vector<std::string> &_headers);
496 
500  private: void AddServerConfigParametersToHeaders(
501  const gz::fuel_tools::ServerConfig &_serverConfig,
502  std::vector<std::string> &_headers) const;
503 
505  private: std::unique_ptr<FuelClientPrivate> dataPtr;
506  };
507  }
508 }
509 
510 #ifdef _MSC_VER
511 #pragma warning(pop)
512 #endif
513 
514 #endif
High level interface to ignition fuel.
Definition: gz/fuel_tools/ClientConfig.hh:109
class for iterating through models
Definition: gz/fuel_tools/ModelIter.hh:43
Result UploadModel(const std::string &_pathToModelDir, const ModelIdentifier &_id, const std::vector< std::string > &_headers, bool _private=false)
Upload a directory as a new model.
STL class.
High level interface to ignition fuel.
Definition: gz/fuel_tools/FuelClient.hh:53
STL class.
ClientConfig & Config()
Get a mutable reference to the client configuration.
Result PatchModel(const ModelIdentifier &_model, const std::vector< std::string > &_headers)
Update a model using a PATCH request.
Defines how to identify a model.
Definition: gz/fuel_tools/ModelIdentifier.hh:45
std::vector< ModelResult > DownloadModels(const std::vector< ModelIdentifier > &_ids, size_t _jobs=2)
Download a list of models from ignition fuel.
ModelIter Models(const ServerConfig &_server)
Returns an iterator that can return names of models.
Class describing a result of an operation.
Definition: gz/fuel_tools/Result.hh:91
Result DeleteModel(const ModelIdentifier &_id)
Remove a model from ignition fuel.
class for iterating through worlds
Definition: gz/fuel_tools/WorldIter.hh:42
bool UpdateModels(const std::vector< std::string > &_headers)
Update all models in local cache.
Result CachedWorld(const common::URI &_worldUrl, std::string &_path)
Check if a world is already present in the local cache.
bool ParseCollectionUrl(const common::URI &_url, CollectionIdentifier &_id)
Parse Collection identifer from URL.
bool ParseModelUrl(const common::URI &_modelUrl, ModelIdentifier &_id)
Parse model identifier from model URL or unique name.
Result DownloadWorld(WorldIdentifier &_id)
Download a world from Ignition Fuel. This will override an existing local copy of the world.
Result DownloadModel(const ModelIdentifier &_id)
Download a model from ignition fuel. This will override an existing local copy of the model.
Describes options needed for a server.
Definition: gz/fuel_tools/ClientConfig.hh:47
bool ParseModelFileUrl(const common::URI &_modelFileUrl, ModelIdentifier &_id, std::string &_filePath)
Parse model file identifier from model file URL.
Result ModelDependencies(const ModelIdentifier &_id, std::vector< ModelIdentifier > &_dependencies)
Retrieve the list of dependencies for a model.
bool ParseWorldUrl(const common::URI &_worldUrl, WorldIdentifier &_id)
Parse world identifier from world URL or unique name.
Result DeleteUrl(const gz::common::URI &_uri, const std::vector< std::string > &_headers)
Remove a resource, such as a model or world, from Ignition Fuel.
bool UpdateWorlds(const std::vector< std::string > &_headers)
Update all worlds in local cache.
Result ModelDetails(const ModelIdentifier &_id, ModelIdentifier &_model) const
Fetch the details of a model.
A helper class for making REST requests.
Definition: gz/fuel_tools/RestClient.hh:82
Result CachedModel(const common::URI &_modelUrl, std::string &_path)
Check if a model is already present in the local cache.
Defines how to identify a world.
Definition: gz/fuel_tools/WorldIdentifier.hh:42
void PopulateLicenses(const ServerConfig &_server)
This function requests the available licenses from the Fuel server and stores this information locall...
bool ParseWorldFileUrl(const common::URI &_worldFileUrl, WorldIdentifier &_id, std::string &_filePath)
Parse world file identifier from world file URL.
Result CachedModelFile(const common::URI &_fileUrl, std::string &_path)
Check if a file belonging to a model is already present in the local cache.
Defines how to identify a collection.
Definition: gz/fuel_tools/CollectionIdentifier.hh:42
Result CachedWorldFile(const common::URI &_fileUrl, std::string &_path)
Check if a file belonging to a world is already present in the local cache.
Result DownloadWorlds(const std::vector< WorldIdentifier > &_ids, size_t _jobs=2)
Download a list of mworlds from ignition fuel.
FuelClient()
Default constructor.
WorldIter Worlds(const ServerConfig &_server) const
Returns an iterator that can return information of worlds.
Result WorldDetails(const WorldIdentifier &_id, WorldIdentifier &_world) const
Fetch the details of a world.
Class for managing stuff in the local cache.
Definition: gz/fuel_tools/LocalCache.hh:46