1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "common/ceph_json.h"
8 #include "rgw_rest_user.h"
10 #include "include/str_list.h"
11 #include "include/assert.h"
13 #define dout_subsys ceph_subsys_rgw
15 class RGWOp_User_Info
: public RGWRESTOp
{
20 int check_caps(RGWUserCaps
& caps
) override
{
21 return caps
.check_cap("users", RGW_CAP_READ
);
24 void execute() override
;
26 const string
name() override
{ return "get_user_info"; }
29 void RGWOp_User_Info::execute()
31 RGWUserAdminOpState op_state
;
37 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
39 // if uid was not supplied in rest argument, error out now, otherwise we'll
40 // end up initializing anonymous user, for which keys.init will eventually
47 rgw_user
uid(uid_str
);
49 RESTArgs::get_bool(s
, "stats", false, &fetch_stats
);
51 RESTArgs::get_bool(s
, "sync", false, &sync_stats
);
53 op_state
.set_user_id(uid
);
54 op_state
.set_fetch_stats(fetch_stats
);
55 op_state
.set_sync_stats(sync_stats
);
57 http_ret
= RGWUserAdminOp_User::info(store
, op_state
, flusher
);
60 class RGWOp_User_Create
: public RGWRESTOp
{
63 RGWOp_User_Create() {}
65 int check_caps(RGWUserCaps
& caps
) override
{
66 return caps
.check_cap("users", RGW_CAP_WRITE
);
69 void execute() override
;
71 const string
name() override
{ return "create_user"; }
74 void RGWOp_User_Create::execute()
77 std::string display_name
;
79 std::string access_key
;
80 std::string secret_key
;
81 std::string key_type_str
;
83 std::string tenant_name
;
91 int32_t default_max_buckets
= s
->cct
->_conf
->rgw_user_max_buckets
;
93 RGWUserAdminOpState op_state
;
95 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
96 rgw_user
uid(uid_str
);
98 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
99 RESTArgs::get_string(s
, "email", email
, &email
);
100 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
101 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
102 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
103 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
104 RESTArgs::get_string(s
, "tenant", tenant_name
, &tenant_name
);
105 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
106 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
107 RESTArgs::get_int32(s
, "max-buckets", default_max_buckets
, &max_buckets
);
108 RESTArgs::get_bool(s
, "system", false, &system
);
109 RESTArgs::get_bool(s
, "exclusive", false, &exclusive
);
111 if (!s
->user
->system
&& system
) {
112 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
117 if (!tenant_name
.empty()) {
118 uid
.tenant
= tenant_name
;
121 // TODO: validate required args are passed in. (for eg. uid and display_name here)
122 op_state
.set_user_id(uid
);
123 op_state
.set_display_name(display_name
);
124 op_state
.set_user_email(email
);
125 op_state
.set_caps(caps
);
126 op_state
.set_access_key(access_key
);
127 op_state
.set_secret_key(secret_key
);
129 if (!key_type_str
.empty()) {
130 int32_t key_type
= KEY_TYPE_UNDEFINED
;
131 if (key_type_str
.compare("swift") == 0)
132 key_type
= KEY_TYPE_SWIFT
;
133 else if (key_type_str
.compare("s3") == 0)
134 key_type
= KEY_TYPE_S3
;
136 op_state
.set_key_type(key_type
);
139 if (max_buckets
!= default_max_buckets
)
140 op_state
.set_max_buckets(max_buckets
);
142 if (s
->info
.args
.exists("suspended"))
143 op_state
.set_suspension(suspended
);
145 if (s
->info
.args
.exists("system"))
146 op_state
.set_system(system
);
148 if (s
->info
.args
.exists("exclusive"))
149 op_state
.set_exclusive(exclusive
);
152 op_state
.set_generate_key();
154 RGWQuotaInfo bucket_quota
;
155 RGWQuotaInfo user_quota
;
157 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
>= 0) {
158 bucket_quota
.max_objects
= s
->cct
->_conf
->rgw_bucket_default_quota_max_objects
;
159 bucket_quota
.enabled
= true;
162 if (s
->cct
->_conf
->rgw_bucket_default_quota_max_size
>= 0) {
163 bucket_quota
.max_size
= s
->cct
->_conf
->rgw_bucket_default_quota_max_size
;
164 bucket_quota
.enabled
= true;
167 if (s
->cct
->_conf
->rgw_user_default_quota_max_objects
>= 0) {
168 user_quota
.max_objects
= s
->cct
->_conf
->rgw_user_default_quota_max_objects
;
169 user_quota
.enabled
= true;
172 if (s
->cct
->_conf
->rgw_user_default_quota_max_size
>= 0) {
173 user_quota
.max_size
= s
->cct
->_conf
->rgw_user_default_quota_max_size
;
174 user_quota
.enabled
= true;
177 if (bucket_quota
.enabled
) {
178 op_state
.set_bucket_quota(bucket_quota
);
181 if (user_quota
.enabled
) {
182 op_state
.set_user_quota(user_quota
);
185 http_ret
= RGWUserAdminOp_User::create(store
, op_state
, flusher
);
188 class RGWOp_User_Modify
: public RGWRESTOp
{
191 RGWOp_User_Modify() {}
193 int check_caps(RGWUserCaps
& caps
) override
{
194 return caps
.check_cap("users", RGW_CAP_WRITE
);
197 void execute() override
;
199 const string
name() override
{ return "modify_user"; }
202 void RGWOp_User_Modify::execute()
205 std::string display_name
;
207 std::string access_key
;
208 std::string secret_key
;
209 std::string key_type_str
;
218 RGWUserAdminOpState op_state
;
220 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
221 rgw_user
uid(uid_str
);
223 RESTArgs::get_string(s
, "display-name", display_name
, &display_name
);
224 RESTArgs::get_string(s
, "email", email
, &email
);
225 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
226 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
227 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
228 RESTArgs::get_bool(s
, "generate-key", false, &gen_key
);
229 RESTArgs::get_bool(s
, "suspended", false, &suspended
);
230 RESTArgs::get_int32(s
, "max-buckets", RGW_DEFAULT_MAX_BUCKETS
, &max_buckets
);
231 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
233 RESTArgs::get_bool(s
, "system", false, &system
);
235 if (!s
->user
->system
&& system
) {
236 ldout(s
->cct
, 0) << "cannot set system flag by non-system user" << dendl
;
241 op_state
.set_user_id(uid
);
242 op_state
.set_display_name(display_name
);
243 op_state
.set_user_email(email
);
244 op_state
.set_caps(caps
);
245 op_state
.set_access_key(access_key
);
246 op_state
.set_secret_key(secret_key
);
248 if (max_buckets
!= RGW_DEFAULT_MAX_BUCKETS
)
249 op_state
.set_max_buckets(max_buckets
);
252 op_state
.set_generate_key();
254 if (!key_type_str
.empty()) {
255 int32_t key_type
= KEY_TYPE_UNDEFINED
;
256 if (key_type_str
.compare("swift") == 0)
257 key_type
= KEY_TYPE_SWIFT
;
258 else if (key_type_str
.compare("s3") == 0)
259 key_type
= KEY_TYPE_S3
;
261 op_state
.set_key_type(key_type
);
264 if (s
->info
.args
.exists("suspended"))
265 op_state
.set_suspension(suspended
);
267 if (s
->info
.args
.exists("system"))
268 op_state
.set_system(system
);
270 http_ret
= RGWUserAdminOp_User::modify(store
, op_state
, flusher
);
273 class RGWOp_User_Remove
: public RGWRESTOp
{
276 RGWOp_User_Remove() {}
278 int check_caps(RGWUserCaps
& caps
) override
{
279 return caps
.check_cap("users", RGW_CAP_WRITE
);
282 void execute() override
;
284 const string
name() override
{ return "remove_user"; }
287 void RGWOp_User_Remove::execute()
292 RGWUserAdminOpState op_state
;
294 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
295 rgw_user
uid(uid_str
);
297 RESTArgs::get_bool(s
, "purge-data", false, &purge_data
);
299 // FIXME: no double checking
301 op_state
.set_user_id(uid
);
303 op_state
.set_purge_data(purge_data
);
305 http_ret
= RGWUserAdminOp_User::remove(store
, op_state
, flusher
);
308 class RGWOp_Subuser_Create
: public RGWRESTOp
{
311 RGWOp_Subuser_Create() {}
313 int check_caps(RGWUserCaps
& caps
) override
{
314 return caps
.check_cap("users", RGW_CAP_WRITE
);
317 void execute() override
;
319 const string
name() override
{ return "create_subuser"; }
322 void RGWOp_Subuser_Create::execute()
326 std::string secret_key
;
327 std::string access_key
;
328 std::string perm_str
;
329 std::string key_type_str
;
331 bool gen_subuser
= false; // FIXME placeholder
335 uint32_t perm_mask
= 0;
336 int32_t key_type
= KEY_TYPE_SWIFT
;
338 RGWUserAdminOpState op_state
;
340 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
341 rgw_user
uid(uid_str
);
343 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
344 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
345 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
346 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
347 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
348 //RESTArgs::get_bool(s, "generate-subuser", false, &gen_subuser);
349 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
350 RESTArgs::get_bool(s
, "gen-access-key", false, &gen_access
);
352 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
353 op_state
.set_perm(perm_mask
);
355 op_state
.set_user_id(uid
);
356 op_state
.set_subuser(subuser
);
357 op_state
.set_access_key(access_key
);
358 op_state
.set_secret_key(secret_key
);
359 op_state
.set_generate_subuser(gen_subuser
);
362 op_state
.set_gen_access();
365 op_state
.set_gen_secret();
367 if (!key_type_str
.empty()) {
368 if (key_type_str
.compare("swift") == 0)
369 key_type
= KEY_TYPE_SWIFT
;
370 else if (key_type_str
.compare("s3") == 0)
371 key_type
= KEY_TYPE_S3
;
373 op_state
.set_key_type(key_type
);
375 http_ret
= RGWUserAdminOp_Subuser::create(store
, op_state
, flusher
);
378 class RGWOp_Subuser_Modify
: public RGWRESTOp
{
381 RGWOp_Subuser_Modify() {}
383 int check_caps(RGWUserCaps
& caps
) override
{
384 return caps
.check_cap("users", RGW_CAP_WRITE
);
387 void execute() override
;
389 const string
name() override
{ return "modify_subuser"; }
392 void RGWOp_Subuser_Modify::execute()
396 std::string secret_key
;
397 std::string key_type_str
;
398 std::string perm_str
;
400 RGWUserAdminOpState op_state
;
403 int32_t key_type
= KEY_TYPE_SWIFT
;
407 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
408 rgw_user
uid(uid_str
);
410 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
411 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
412 RESTArgs::get_string(s
, "access", perm_str
, &perm_str
);
413 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
414 RESTArgs::get_bool(s
, "generate-secret", false, &gen_secret
);
416 perm_mask
= rgw_str_to_perm(perm_str
.c_str());
417 op_state
.set_perm(perm_mask
);
419 op_state
.set_user_id(uid
);
420 op_state
.set_subuser(subuser
);
422 if (!secret_key
.empty())
423 op_state
.set_secret_key(secret_key
);
426 op_state
.set_gen_secret();
428 if (!key_type_str
.empty()) {
429 if (key_type_str
.compare("swift") == 0)
430 key_type
= KEY_TYPE_SWIFT
;
431 else if (key_type_str
.compare("s3") == 0)
432 key_type
= KEY_TYPE_S3
;
434 op_state
.set_key_type(key_type
);
436 http_ret
= RGWUserAdminOp_Subuser::modify(store
, op_state
, flusher
);
439 class RGWOp_Subuser_Remove
: public RGWRESTOp
{
442 RGWOp_Subuser_Remove() {}
444 int check_caps(RGWUserCaps
& caps
) override
{
445 return caps
.check_cap("users", RGW_CAP_WRITE
);
448 void execute() override
;
450 const string
name() override
{ return "remove_subuser"; }
453 void RGWOp_Subuser_Remove::execute()
459 RGWUserAdminOpState op_state
;
461 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
462 rgw_user
uid(uid_str
);
464 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
465 RESTArgs::get_bool(s
, "purge-keys", true, &purge_keys
);
467 op_state
.set_user_id(uid
);
468 op_state
.set_subuser(subuser
);
471 op_state
.set_purge_keys();
473 http_ret
= RGWUserAdminOp_Subuser::remove(store
, op_state
, flusher
);
476 class RGWOp_Key_Create
: public RGWRESTOp
{
479 RGWOp_Key_Create() {}
481 int check_caps(RGWUserCaps
& caps
) override
{
482 return caps
.check_cap("users", RGW_CAP_WRITE
);
485 void execute() override
;
487 const string
name() override
{ return "create_access_key"; }
490 void RGWOp_Key_Create::execute()
494 std::string access_key
;
495 std::string secret_key
;
496 std::string key_type_str
;
500 RGWUserAdminOpState op_state
;
502 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
503 rgw_user
uid(uid_str
);
505 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
506 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
507 RESTArgs::get_string(s
, "secret-key", secret_key
, &secret_key
);
508 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
509 RESTArgs::get_bool(s
, "generate-key", true, &gen_key
);
511 op_state
.set_user_id(uid
);
512 op_state
.set_subuser(subuser
);
513 op_state
.set_access_key(access_key
);
514 op_state
.set_secret_key(secret_key
);
517 op_state
.set_generate_key();
519 if (!key_type_str
.empty()) {
520 int32_t key_type
= KEY_TYPE_UNDEFINED
;
521 if (key_type_str
.compare("swift") == 0)
522 key_type
= KEY_TYPE_SWIFT
;
523 else if (key_type_str
.compare("s3") == 0)
524 key_type
= KEY_TYPE_S3
;
526 op_state
.set_key_type(key_type
);
529 http_ret
= RGWUserAdminOp_Key::create(store
, op_state
, flusher
);
532 class RGWOp_Key_Remove
: public RGWRESTOp
{
535 RGWOp_Key_Remove() {}
537 int check_caps(RGWUserCaps
& caps
) override
{
538 return caps
.check_cap("users", RGW_CAP_WRITE
);
541 void execute() override
;
543 const string
name() override
{ return "remove_access_key"; }
546 void RGWOp_Key_Remove::execute()
550 std::string access_key
;
551 std::string key_type_str
;
553 RGWUserAdminOpState op_state
;
555 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
556 rgw_user
uid(uid_str
);
558 RESTArgs::get_string(s
, "subuser", subuser
, &subuser
);
559 RESTArgs::get_string(s
, "access-key", access_key
, &access_key
);
560 RESTArgs::get_string(s
, "key-type", key_type_str
, &key_type_str
);
562 op_state
.set_user_id(uid
);
563 op_state
.set_subuser(subuser
);
564 op_state
.set_access_key(access_key
);
566 if (!key_type_str
.empty()) {
567 int32_t key_type
= KEY_TYPE_UNDEFINED
;
568 if (key_type_str
.compare("swift") == 0)
569 key_type
= KEY_TYPE_SWIFT
;
570 else if (key_type_str
.compare("s3") == 0)
571 key_type
= KEY_TYPE_S3
;
573 op_state
.set_key_type(key_type
);
576 http_ret
= RGWUserAdminOp_Key::remove(store
, op_state
, flusher
);
579 class RGWOp_Caps_Add
: public RGWRESTOp
{
584 int check_caps(RGWUserCaps
& caps
) override
{
585 return caps
.check_cap("users", RGW_CAP_WRITE
);
588 void execute() override
;
590 const string
name() override
{ return "add_user_caps"; }
593 void RGWOp_Caps_Add::execute()
598 RGWUserAdminOpState op_state
;
600 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
601 rgw_user
uid(uid_str
);
603 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
605 op_state
.set_user_id(uid
);
606 op_state
.set_caps(caps
);
608 http_ret
= RGWUserAdminOp_Caps::add(store
, op_state
, flusher
);
611 class RGWOp_Caps_Remove
: public RGWRESTOp
{
614 RGWOp_Caps_Remove() {}
616 int check_caps(RGWUserCaps
& caps
) override
{
617 return caps
.check_cap("users", RGW_CAP_WRITE
);
620 void execute() override
;
622 const string
name() override
{ return "remove_user_caps"; }
625 void RGWOp_Caps_Remove::execute()
630 RGWUserAdminOpState op_state
;
632 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
633 rgw_user
uid(uid_str
);
635 RESTArgs::get_string(s
, "user-caps", caps
, &caps
);
637 op_state
.set_user_id(uid
);
638 op_state
.set_caps(caps
);
640 http_ret
= RGWUserAdminOp_Caps::remove(store
, op_state
, flusher
);
644 RGWQuotaInfo bucket_quota
;
645 RGWQuotaInfo user_quota
;
649 explicit UserQuotas(RGWUserInfo
& info
) : bucket_quota(info
.bucket_quota
),
650 user_quota(info
.user_quota
) {}
652 void dump(Formatter
*f
) const {
653 encode_json("bucket_quota", bucket_quota
, f
);
654 encode_json("user_quota", user_quota
, f
);
656 void decode_json(JSONObj
*obj
) {
657 JSONDecoder::decode_json("bucket_quota", bucket_quota
, obj
);
658 JSONDecoder::decode_json("user_quota", user_quota
, obj
);
662 class RGWOp_Quota_Info
: public RGWRESTOp
{
665 RGWOp_Quota_Info() {}
667 int check_caps(RGWUserCaps
& caps
) override
{
668 return caps
.check_cap("users", RGW_CAP_READ
);
671 void execute() override
;
673 const string
name() override
{ return "get_quota_info"; }
677 void RGWOp_Quota_Info::execute()
679 RGWUserAdminOpState op_state
;
682 std::string quota_type
;
684 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
685 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
687 if (uid_str
.empty()) {
692 rgw_user
uid(uid_str
);
694 bool show_all
= quota_type
.empty();
695 bool show_bucket
= show_all
|| (quota_type
== "bucket");
696 bool show_user
= show_all
|| (quota_type
== "user");
698 if (!(show_all
|| show_bucket
|| show_user
)) {
703 op_state
.set_user_id(uid
);
706 http_ret
= user
.init(store
, op_state
);
710 if (!op_state
.has_existing_user()) {
711 http_ret
= -ERR_NO_SUCH_USER
;
717 http_ret
= user
.info(info
, &err_msg
);
723 UserQuotas
quotas(info
);
724 encode_json("quota", quotas
, s
->formatter
);
725 } else if (show_user
) {
726 encode_json("user_quota", info
.user_quota
, s
->formatter
);
728 encode_json("bucket_quota", info
.bucket_quota
, s
->formatter
);
734 class RGWOp_Quota_Set
: public RGWRESTOp
{
739 int check_caps(RGWUserCaps
& caps
) override
{
740 return caps
.check_cap("users", RGW_CAP_WRITE
);
743 void execute() override
;
745 const string
name() override
{ return "set_quota_info"; }
751 * two different ways to set the quota info: as json struct in the message body or via http params.
755 * PUT /admin/user?uid=<uid>["a-type=<type>]
757 * whereas quota-type is optional and is either user, or bucket
759 * if quota-type is not specified then we expect to get a structure that contains both quotas,
760 * otherwise we'll only get the relevant configuration.
762 * E.g., if quota type not specified:
765 * "max_size_kb" : 4096,
766 * "max_objects" : -1,
770 * "max_size_kb" : 1024,
771 * "max_objects" : -1,
777 * or if quota type is specified:
779 * "max_size_kb" : 4096,
780 * "max_objects" : -1,
784 * Another option is not to pass any body and set the following http params:
788 * max-objects=<max objects>
789 * enabled[={true,false}]
791 * all params are optionals and default to the current settings. With this type of configuration the
792 * quota-type param is mandatory.
796 void RGWOp_Quota_Set::execute()
798 RGWUserAdminOpState op_state
;
801 std::string quota_type
;
803 RESTArgs::get_string(s
, "uid", uid_str
, &uid_str
);
804 RESTArgs::get_string(s
, "quota-type", quota_type
, "a_type
);
806 if (uid_str
.empty()) {
811 rgw_user
uid(uid_str
);
813 bool set_all
= quota_type
.empty();
814 bool set_bucket
= set_all
|| (quota_type
== "bucket");
815 bool set_user
= set_all
|| (quota_type
== "user");
817 if (!(set_all
|| set_bucket
|| set_user
)) {
818 ldout(store
->ctx(), 20) << "invalid quota type" << dendl
;
823 bool use_http_params
;
825 if (s
->content_length
> 0) {
826 use_http_params
= false;
828 const char *encoding
= s
->info
.env
->get("HTTP_TRANSFER_ENCODING");
829 use_http_params
= (!encoding
|| strcmp(encoding
, "chunked") != 0);
832 if (use_http_params
&& set_all
) {
833 ldout(store
->ctx(), 20) << "quota type was not specified, can't set all quotas via http headers" << dendl
;
838 op_state
.set_user_id(uid
);
841 http_ret
= user
.init(store
, op_state
);
843 ldout(store
->ctx(), 20) << "failed initializing user info: " << http_ret
<< dendl
;
847 if (!op_state
.has_existing_user()) {
848 http_ret
= -ERR_NO_SUCH_USER
;
852 #define QUOTA_INPUT_MAX_LEN 1024
856 if ((http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quotas
, QUOTA_INPUT_MAX_LEN
, NULL
)) < 0) {
857 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
861 op_state
.set_user_quota(quotas
.user_quota
);
862 op_state
.set_bucket_quota(quotas
.bucket_quota
);
866 if (!use_http_params
) {
868 http_ret
= rgw_rest_get_json_input(store
->ctx(), s
, quota
, QUOTA_INPUT_MAX_LEN
, &empty
);
870 ldout(store
->ctx(), 20) << "failed to retrieve input" << dendl
;
874 /* was probably chunked input, but no content provided, configure via http params */
875 use_http_params
= true;
879 if (use_http_params
) {
882 http_ret
= user
.info(info
, &err_msg
);
884 ldout(store
->ctx(), 20) << "failed to get user info: " << http_ret
<< dendl
;
887 RGWQuotaInfo
*old_quota
;
889 old_quota
= &info
.user_quota
;
891 old_quota
= &info
.bucket_quota
;
894 int64_t old_max_size_kb
= rgw_rounded_kb(old_quota
->max_size
);
896 RESTArgs::get_int64(s
, "max-objects", old_quota
->max_objects
, "a
.max_objects
);
897 RESTArgs::get_int64(s
, "max-size-kb", old_max_size_kb
, &max_size_kb
);
898 quota
.max_size
= max_size_kb
* 1024;
899 RESTArgs::get_bool(s
, "enabled", old_quota
->enabled
, "a
.enabled
);
903 op_state
.set_user_quota(quota
);
905 op_state
.set_bucket_quota(quota
);
910 http_ret
= user
.modify(op_state
, &err
);
912 ldout(store
->ctx(), 20) << "failed updating user info: " << http_ret
<< ": " << err
<< dendl
;
917 RGWOp
*RGWHandler_User::op_get()
919 if (s
->info
.args
.sub_resource_exists("quota"))
920 return new RGWOp_Quota_Info
;
922 return new RGWOp_User_Info
;
925 RGWOp
*RGWHandler_User::op_put()
927 if (s
->info
.args
.sub_resource_exists("subuser"))
928 return new RGWOp_Subuser_Create
;
930 if (s
->info
.args
.sub_resource_exists("key"))
931 return new RGWOp_Key_Create
;
933 if (s
->info
.args
.sub_resource_exists("caps"))
934 return new RGWOp_Caps_Add
;
936 if (s
->info
.args
.sub_resource_exists("quota"))
937 return new RGWOp_Quota_Set
;
939 return new RGWOp_User_Create
;
942 RGWOp
*RGWHandler_User::op_post()
944 if (s
->info
.args
.sub_resource_exists("subuser"))
945 return new RGWOp_Subuser_Modify
;
947 return new RGWOp_User_Modify
;
950 RGWOp
*RGWHandler_User::op_delete()
952 if (s
->info
.args
.sub_resource_exists("subuser"))
953 return new RGWOp_Subuser_Remove
;
955 if (s
->info
.args
.sub_resource_exists("key"))
956 return new RGWOp_Key_Remove
;
958 if (s
->info
.args
.sub_resource_exists("caps"))
959 return new RGWOp_Caps_Remove
;
961 return new RGWOp_User_Remove
;