Gazebo Fuel_tools

API Reference

4.9.1
gz/fuel_tools/RestClient.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 #ifndef GZ_FUEL_TOOLS_RESTCLIENT_HH_
18 #define GZ_FUEL_TOOLS_RESTCLIENT_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "gz/fuel_tools/Export.hh"
26 
27 #ifdef _WIN32
28 // Disable warning C4251 which is triggered by
29 // std::string
30 #pragma warning(push)
31 #pragma warning(disable: 4251)
32 #endif
33 
34 namespace ignition
35 {
36  namespace fuel_tools
37  {
39  struct IGNITION_FUEL_TOOLS_VISIBLE RestResponse
40  {
42  // cppcheck-suppress unusedStructMember
43  public: int statusCode = 0;
44 
46  public: std::string data = "";
47 
52  };
53 
55  enum class HttpMethod
56  {
58  GET,
59 
61  POST,
62 
64  DELETE,
65 
67  PUT,
68 
70  PATCH,
71 
73  POST_FORM,
74 
77  };
78 
80  class IGNITION_FUEL_TOOLS_VISIBLE Rest
81  {
83  public: Rest() = default;
84 
109  public: virtual RestResponse Request(const HttpMethod _method,
110  const std::string &_url,
111  const std::string &_version,
112  const std::string &_path,
113  const std::vector<std::string> &_queryStrings,
114  const std::vector<std::string> &_headers,
115  const std::string &_data,
118 
121  public: void SetUserAgent(const std::string &_agent);
122 
125  public: const std::string &UserAgent() const;
126 
128  private: std::string userAgent;
129  };
130  }
131 }
132 
133 #ifdef _MSC_VER
134 #pragma warning(pop)
135 #endif
136 
137 #endif
STL class.
STL class.
int statusCode
The returned status code. E.g.: 200.
Definition: gz/fuel_tools/RestClient.hh:43
void SetUserAgent(const std::string &_agent)
Set the user agent name.
HttpMethod
the types of HTTP methods
Definition: gz/fuel_tools/RestClient.hh:55
Rest()=default
Default constructor.
virtual RestResponse Request(const HttpMethod _method, const std::string &_url, const std::string &_version, const std::string &_path, const std::vector< std::string > &_queryStrings, const std::vector< std::string > &_headers, const std::string &_data, const std::multimap< std::string, std::string > &_form=std::multimap< std::string, std::string >()) const
Trigger a REST request.
Stores a response to a RESTful request.
Definition: gz/fuel_tools/RestClient.hh:39
@ PATCH_FORM
Patch form method.
const std::string & UserAgent() const
Get the user agent name.
std::string data
The data received.
Definition: gz/fuel_tools/RestClient.hh:46
A helper class for making REST requests.
Definition: gz/fuel_tools/RestClient.hh:80
std::map< std::string, std::string > headers
Map of headers where the key is the header type. For example, a raw header of the form "Content-Type:...
Definition: gz/fuel_tools/RestClient.hh:51
STL class.