};
template <class S, class T>
-class RGWPostRESTResourceCR : public RGWSimpleCoroutine {
+class RGWSendRESTResourceCR : public RGWSimpleCoroutine {
RGWRESTConn *conn;
RGWHTTPManager *http_manager;
+ string method;
string path;
param_vec_t params;
T *result;
S input;
- boost::intrusive_ptr<RGWRESTPostResource> http_op;
+ boost::intrusive_ptr<RGWRESTSendResource> http_op;
public:
- RGWPostRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
- RGWHTTPManager *_http_manager, const string& _path,
+ RGWSendRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+ RGWHTTPManager *_http_manager,
+ const string& _method, const string& _path,
rgw_http_param_pair *_params, S& _input, T *_result)
: RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
- path(_path), params(make_param_list(_params)), result(_result),
+ method(_method), path(_path), params(make_param_list(_params)), result(_result),
input(_input)
{}
- ~RGWPostRESTResourceCR() {
+ ~RGWSendRESTResourceCR() {
request_cleanup();
}
int send_request() {
- auto op = boost::intrusive_ptr<RGWRESTPostResource>(
- new RGWRESTPostResource(conn, path, params, NULL, http_manager));
+ auto op = boost::intrusive_ptr<RGWRESTSendResource>(
+ new RGWRESTSendResource(conn, method, path, params, NULL, http_manager));
op->set_user_info((void *)stack);
}
};
+template <class S, class T>
+class RGWPostRESTResourceCR : public RGWSendRESTResourceCR<S, T> {
+public:
+ RGWPostRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+ RGWHTTPManager *_http_manager,
+ const string& _path,
+ rgw_http_param_pair *_params, S& _input, T *_result)
+ : RGWSendRESTResourceCR<S, T>(_cct, _conn, _http_manager,
+ "POST", _path,
+ _params, _input, _result) {}
+};
+
+template <class S, class T>
+class RGWPutRESTResourceCR : public RGWSendRESTResourceCR<S, T> {
+public:
+ RGWPutRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+ RGWHTTPManager *_http_manager,
+ const string& _path,
+ rgw_http_param_pair *_params, S& _input, T *_result)
+ : RGWSendRESTResourceCR<S, T>(_cct, _conn, _http_manager,
+ "PUT", _path,
+ _params, _input, _result) {}
+};
+
#endif
return 0;
}
-RGWRESTPostResource::RGWRESTPostResource(RGWRESTConn *_conn,
+RGWRESTSendResource::RGWRESTSendResource(RGWRESTConn *_conn,
+ const string& _method,
const string& _resource,
const rgw_http_param_pair *pp,
param_vec_t *extra_headers,
RGWHTTPManager *_mgr)
- : cct(_conn->get_ctx()), conn(_conn), resource(_resource),
+ : cct(_conn->get_ctx()), conn(_conn), method(_method), resource(_resource),
params(make_param_list(pp)), cb(bl), mgr(_mgr),
- req(cct, "POST", conn->get_url(), &cb, NULL, NULL)
+ req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL)
{
init_common(extra_headers);
}
-RGWRESTPostResource::RGWRESTPostResource(RGWRESTConn *_conn,
+RGWRESTSendResource::RGWRESTSendResource(RGWRESTConn *_conn,
+ const string& _method,
const string& _resource,
param_vec_t& params,
param_vec_t *extra_headers,
RGWHTTPManager *_mgr)
- : cct(_conn->get_ctx()), conn(_conn), resource(_resource), params(params),
- cb(bl), mgr(_mgr), req(cct, "POST", conn->get_url(), &cb, NULL, NULL)
+ : cct(_conn->get_ctx()), conn(_conn), method(_method), resource(_resource), params(params),
+ cb(bl), mgr(_mgr), req(cct, method.c_str(), conn->get_url(), &cb, NULL, NULL)
{
init_common(extra_headers);
}
-void RGWRESTPostResource::init_common(param_vec_t *extra_headers)
+void RGWRESTSendResource::init_common(param_vec_t *extra_headers)
{
params.push_back(param_pair_t(RGW_SYS_PARAM_PREFIX "zonegroup", conn->get_self_zonegroup()));
req.set_params(¶ms);
}
-int RGWRESTPostResource::send(bufferlist& outbl)
+int RGWRESTSendResource::send(bufferlist& outbl)
{
req.set_outbl(outbl);
int ret = req.get_resource(conn->get_key(), headers, resource, mgr);
return req.complete(etag, NULL, NULL, attrs);
}
-int RGWRESTPostResource::aio_send(bufferlist& outbl)
+int RGWRESTSendResource::aio_send(bufferlist& outbl)
{
req.set_outbl(outbl);
int ret = req.get_resource(conn->get_key(), headers, resource, mgr);
return 0;
}
-class RGWRESTPostResource : public RefCountedObject {
+class RGWRESTSendResource : public RefCountedObject {
CephContext *cct;
RGWRESTConn *conn;
+ string method;
string resource;
param_vec_t params;
map<string, string> headers;
void init_common(param_vec_t *extra_headers);
public:
- RGWRESTPostResource(RGWRESTConn *_conn,
+ RGWRESTSendResource(RGWRESTConn *_conn,
+ const string& _method,
const string& _resource,
const rgw_http_param_pair *pp,
param_vec_t *extra_headers,
RGWHTTPManager *_mgr);
- RGWRESTPostResource(RGWRESTConn *_conn,
+ RGWRESTSendResource(RGWRESTConn *_conn,
+ const string& _method,
const string& _resource,
param_vec_t& params,
param_vec_t *extra_headers,
};
template <class T>
-int RGWRESTPostResource::decode_resource(T *dest)
+int RGWRESTSendResource::decode_resource(T *dest)
{
int ret = req.get_status();
if (ret < 0) {
}
template <class T>
-int RGWRESTPostResource::wait(T *dest)
+int RGWRESTSendResource::wait(T *dest)
{
int ret = req.wait();
if (ret < 0) {
return 0;
}
+class RGWRESTPostResource : public RGWRESTSendResource {
+public:
+ RGWRESTPostResource(RGWRESTConn *_conn,
+ const string& _resource,
+ const rgw_http_param_pair *pp,
+ param_vec_t *extra_headers,
+ RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "POST", _resource,
+ pp, extra_headers, _mgr) {}
+
+ RGWRESTPostResource(RGWRESTConn *_conn,
+ const string& _resource,
+ param_vec_t& params,
+ param_vec_t *extra_headers,
+ RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "POST", _resource,
+ params, extra_headers, _mgr) {}
+
+};
+
+class RGWRESTPutResource : public RGWRESTSendResource {
+public:
+ RGWRESTPutResource(RGWRESTConn *_conn,
+ const string& _resource,
+ const rgw_http_param_pair *pp,
+ param_vec_t *extra_headers,
+ RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "PUT", _resource,
+ pp, extra_headers, _mgr) {}
+
+ RGWRESTPutResource(RGWRESTConn *_conn,
+ const string& _resource,
+ param_vec_t& params,
+ param_vec_t *extra_headers,
+ RGWHTTPManager *_mgr) : RGWRESTSendResource(_conn, "PUT", _resource,
+ params, extra_headers, _mgr) {}
+
+};
+
+
#endif