Gazebo Fuel_tools

API Reference

8.2.0
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 // TODO(jrivero): rename the DELETE method which is a reserved word in Windows
33 #undef DELETE
34 #endif
35 
36 namespace gz
37 {
38  namespace fuel_tools
39  {
41  struct GZ_FUEL_TOOLS_VISIBLE RestResponse
42  {
44  // cppcheck-suppress unusedStructMember
45  public: int statusCode = 0;
46 
48  public: std::string data = "";
49 
54  };
55 
57  enum class HttpMethod
58  {
60  GET,
61 
63  POST,
64 
66  DELETE,
67 
69  PUT,
70 
72  PATCH,
73 
75  POST_FORM,
76 
79  };
80 
82  class GZ_FUEL_TOOLS_VISIBLE Rest
83  {
85  public: Rest() = default;
86 
111  public: virtual RestResponse Request(const HttpMethod _method,
112  const std::string &_url,
113  const std::string &_version,
114  const std::string &_path,
115  const std::vector<std::string> &_queryStrings,
116  const std::vector<std::string> &_headers,
117  const std::string &_data,
120 
123  public: void SetUserAgent(const std::string &_agent);
124 
127  public: const std::string &UserAgent() const;
128 
130  private: std::string userAgent;
131  };
132  }
133 }
134 
135 #ifdef _MSC_VER
136 #pragma warning(pop)
137 #endif
138 
139 #endif